diff options
Diffstat (limited to 'src/libutil/rust-ffi.cc')
-rw-r--r-- | src/libutil/rust-ffi.cc | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/src/libutil/rust-ffi.cc b/src/libutil/rust-ffi.cc index accc5e22b..8b8b7b75d 100644 --- a/src/libutil/rust-ffi.cc +++ b/src/libutil/rust-ffi.cc @@ -3,10 +3,14 @@ extern "C" std::exception_ptr * make_error(rust::StringSlice s) { - // FIXME: leak return new std::exception_ptr(std::make_exception_ptr(nix::Error(std::string(s.ptr, s.size)))); } +extern "C" void destroy_error(std::exception_ptr * ex) +{ + free(ex); +} + namespace rust { std::ostream & operator << (std::ostream & str, const String & s) @@ -15,4 +19,15 @@ std::ostream & operator << (std::ostream & str, const String & s) return str; } +size_t Source::sourceWrapper(void * _this, rust::Slice<uint8_t> data) +{ + try { + // FIXME: how to propagate exceptions? + auto n = ((nix::Source *) _this)->read((unsigned char *) data.ptr, data.size); + return n; + } catch (...) { + abort(); + } +} + } |