pub trait Handler {
    // Required methods
    fn wrap<PrepareFn, TaskFn, TaskRet, D, Er>(
        &self,
        wrap_info: WrapInfo,
        prepare: PrepareFn
    )
       where PrepareFn: FnOnce() -> TaskFn + UnwindSafe,
             TaskFn: FnOnce(TaskCallback) -> Result<TaskRet, Er> + Send + UnwindSafe + 'static,
             TaskRet: IntoIntoDart<D>,
             D: IntoDart,
             Er: IntoDart + 'static;
    fn wrap_sync<SyncTaskFn, TaskRet, D, Er>(
        &self,
        wrap_info: WrapInfo,
        sync_task: SyncTaskFn
    ) -> WireSyncReturn
       where SyncTaskFn: FnOnce() -> Result<SyncReturn<TaskRet>, Er> + UnwindSafe,
             TaskRet: IntoIntoDart<D>,
             D: IntoDart,
             Er: IntoDart + 'static;
}
Expand description

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

Required Methods§

source

fn wrap<PrepareFn, TaskFn, TaskRet, D, Er>( &self, wrap_info: WrapInfo, prepare: PrepareFn )
where PrepareFn: FnOnce() -> TaskFn + UnwindSafe, TaskFn: FnOnce(TaskCallback) -> Result<TaskRet, Er> + Send + UnwindSafe + 'static, TaskRet: IntoIntoDart<D>, D: IntoDart, Er: IntoDart + 'static,

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.

source

fn wrap_sync<SyncTaskFn, TaskRet, D, Er>( &self, wrap_info: WrapInfo, sync_task: SyncTaskFn ) -> WireSyncReturn
where SyncTaskFn: FnOnce() -> Result<SyncReturn<TaskRet>, Er> + UnwindSafe, TaskRet: IntoIntoDart<D>, D: IntoDart, Er: IntoDart + 'static,

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

Object Safety§

This trait is not object safe.

Implementors§