diff --git a/native/native_rust_library/RustCallback.h b/native/native_rust_library/RustCallback.h --- a/native/native_rust_library/RustCallback.h +++ b/native/native_rust_library/RustCallback.h @@ -5,5 +5,6 @@ namespace comm { void stringCallback(rust::String error, uint32_t promiseID, rust::String ret); +void voidCallback(rust::String error, uint32_t promiseID); } // namespace comm diff --git a/native/native_rust_library/RustCallback.cpp b/native/native_rust_library/RustCallback.cpp --- a/native/native_rust_library/RustCallback.cpp +++ b/native/native_rust_library/RustCallback.cpp @@ -23,4 +23,18 @@ } } +void voidCallback(rust::String error, uint32_t promiseID) { + auto it = RustPromiseManager::instance.promises.find(promiseID); + if (it == RustPromiseManager::instance.promises.end()) { + return; + } + + if (error.size()) { + RustPromiseManager::instance.rejectPromise(promiseID, std::string(error)); + } else { + RustPromiseManager::instance.resolvePromise( + promiseID, folly::dynamic(nullptr)); + } +} + } // namespace comm