pub trait Handler {
    fn wrap<PrepareFn, TaskFn, TaskRet>(
        &self,
        wrap_info: WrapInfo,
        prepare: PrepareFn
    )
    where
        PrepareFn: FnOnce() -> TaskFn + UnwindSafe,
        TaskFn: FnOnce(TaskCallback) -> Result<TaskRet> + Send + UnwindSafe + 'static,
        TaskRet: IntoDart
; fn wrap_sync<SyncTaskFn>(
        &self,
        wrap_info: WrapInfo,
        sync_task: SyncTaskFn
    ) -> WireSyncReturnStruct
    where
        SyncTaskFn: FnOnce() -> Result<SyncReturn<Vec<u8>>> + UnwindSafe
; }
Expand description

Provide your own handler to customize how to execute your function calls, etc.

Required Methods

Prepares the arguments, executes a Rust function and sets up its return value.

Why separate PrepareFn and TaskFn: because some things cannot be Send (e.g. raw pointers), so those can be done in PrepareFn, while the real work is done in TaskFn with Send.

The generated code depends on the fact that PrepareFn is synchronous to maintain correctness, therefore implementors of Handler must also uphold this property.

If a Rust function returns SyncReturn, it must be called with wrap_sync instead.

Same as wrap, but the Rust function must return a SyncReturn and need not implement Send.

Implementors