From ac9cc2ec08e95910ecb73745cb011596a33723f0 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Fri, 13 Dec 2019 19:10:39 +0100 Subject: [PATCH] Move some code --- src/libutil/rust-ffi.cc | 11 +++++++++++ src/libutil/rust-ffi.hh | 7 +------ 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/src/libutil/rust-ffi.cc b/src/libutil/rust-ffi.cc index 6f36b3192..8b8b7b75d 100644 --- a/src/libutil/rust-ffi.cc +++ b/src/libutil/rust-ffi.cc @@ -19,4 +19,15 @@ std::ostream & operator << (std::ostream & str, const String & s) return str; } +size_t Source::sourceWrapper(void * _this, rust::Slice data) +{ + try { + // FIXME: how to propagate exceptions? + auto n = ((nix::Source *) _this)->read((unsigned char *) data.ptr, data.size); + return n; + } catch (...) { + abort(); + } +} + } diff --git a/src/libutil/rust-ffi.hh b/src/libutil/rust-ffi.hh index 4fecce606..3b51661c2 100644 --- a/src/libutil/rust-ffi.hh +++ b/src/libutil/rust-ffi.hh @@ -140,12 +140,7 @@ struct Source : fun(sourceWrapper), _this(&_this) {} - // FIXME: how to propagate exceptions? - static size_t sourceWrapper(void * _this, rust::Slice data) - { - auto n = ((nix::Source *) _this)->read((unsigned char *) data.ptr, data.size); - return n; - } + static size_t sourceWrapper(void * _this, rust::Slice data); }; /* C++ representation of Rust's Result. */