jerel / membrane

Membrane is an opinionated crate that generates a Dart package from a Rust library. Extremely fast performance with strict typing and zero copy returns over the FFI boundary via bincode.
Apache License 2.0
89 stars 12 forks source link

Add timeout functionality for async receive ports #6

Closed jerel closed 2 years ago

jerel commented 2 years ago

While previous releases contained a call to timeout(Duration(milliseconds: 1000)) on the codegenerated ReceivePort the timeout did not actually throw an exception if it was reached due to the behavior of ReceivePort()..timeout(). This PR fixes that bug and makes timeouts configurable at the project level and also at the function level. Timeouts can now be customized (even on streams) by passing the timeout option to async_dart. Example:

#[async_dart(namespace = "foo", timeout = 200)]
pub async fn example() -> Result<String, String> {}