pub trait IntoDispatcher<Args, Ret, M> {
type Target;
type Output: BorrowMut<Self::Target>;
// Required method
fn into_dispatcher(self) -> Self::Output;
}Expand description
Convert a dispatcher, a callback, or a tuple of them, into a Dispatcher
for the argument tuple Args and result Ret; the traversals take any of
these inputs.
- An owned
Dor a borrowed&mut DkeepsDas theTarget, and must have exactly that signature. - A callback takes a leading prefix of one to four of the arguments, and
its first parameter selects what it matches, as for a
#[dispatch]handler: an FFI value, a borrowed object node orAnyView, or a typedMutationViewfor mutation. It is passed by value,&or&mut. - A tuple, possibly nested, tries its links in order. Only an outer
Nonemoves on to the next link; an error or an innerNonestops.
M marks the input form and is inferred; when calling into_dispatcher
directly, give Args and Ret. See also #[dispatch].
use tvm_ffi::{Any, AnyView, Dispatcher, IntoDispatcher, Result};
let callbacks = (|value: i64| Any::from(value + 1), |_value: AnyView<'_>| Any::new());
let mut dispatcher = IntoDispatcher::<(AnyView<'_>,), Option<Result<Any>>, _>::into_dispatcher(callbacks);
let result: Option<Result<Any>> = dispatcher.dispatch_tuple((AnyView::from(&41_i64),));
let result = result.unwrap()?;
assert_eq!(i64::try_from(result)?, 42);Required Associated Types§
Required Methods§
Sourcefn into_dispatcher(self) -> Self::Output
fn into_dispatcher(self) -> Self::Output
Convert the input, once, before the traversal starts.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".