Crate flutter_rust_bridge
source ·Expand description
Main documentation is in https://github.com/fzyzcjy/flutter_rust_bridge
Macros
- Macro helper to instantiate an
RustOpaque<dyn Trait>
, as Rust does not support custom DSTs on stable. - On WASM,
JsValue
s cannot be shared between scopes but instead can be “transferred”. Rust however is not aware of transferables and therefore cannot capture these values. This macro wraps a closure and returns aTransferClosure
on WASM platforms which will capture these special values, or a normal FnOnce on other platforms. Note that the parameter names must match available variables/bindings from the outer scope.
Structs
- Arbitrary Dart object, whose type can be even non-encodable and non-transferable.
- An owned permission to join on a task (await its termination).
- Error when sending message from rust to dart
- Codec that does a simple serialization
- Wrapping a Vec
in this tuple struct will allow into_dart() to send it as a DartNativeExternalTypedData buffer with no copy overhead
Traits
- DartSafeDeprecated
- Provide your own handler to customize how to execute your function calls, etc.
- A trait to convert between Rust types and Dart Types that could then be sent to the isolate
- Basically the Into trait. We need this separate trait because we need to implement it for Vec
etc. These blanket implementations allow us to accept external types in various places. The initial reason for this was to allow mirrored types in StreamSink<>. See also PR 1285
Functions
- Setup defaults that is usually useful for a new project. Surely, you are free to customize everything.
- Spawns a new asynchronous task, returning a
JoinHandle
for it. - Similar to tokio’s
spawn_blocking
, except that you need to provide a second argumnet. If you are using flutter_rust_bridge, the second argument can be easily provided: Just useFLUTTER_RUST_BRIDGE_HANDLER.thread_pool()
. - Spawns a
!Send
future on the currentLocalSet
.
Type Aliases
- Use this type to represent Dart
dynamic
values - Roughly speaking, just BoxFuture + UnwindSafe.
- The default handler used by the generated code.
- Please refer to
RustAutoOpaque
for doc. - Please refer to
RustOpaque
for doc.
Attribute Macros
- Attribute to guide code generation.