Skip to main content

Handler

Struct Handler 

Source
pub struct Handler { /* private fields */ }
Expand description

A registered step handler: a closure over (state, args_after_state).

Implementations§

Source§

impl Handler

Source

pub fn noop() -> Handler

A no-op handler (arity-agnostic) — used where a handler is never invoked.

Source

pub fn new( f: impl Fn(Rc<dyn Any>, Vec<Value>) -> HandlerReturn + 'static, ) -> Handler

Builds a handler from a raw closure over the opaque state and the slot arguments. The facade’s typed stimulus/sensor build these; authors use those instead.

Source

pub fn sync0( f: impl Fn(Value) -> Result<Option<Value>, HandlerError> + 'static, ) -> Handler

Fixed-arity conveniences over a Value state. These exist for the core’s own tests and for any consumer not using the varar facade — the facade builds handlers from typed closures instead, so an author never calls these.

Source

pub fn sync1( f: impl Fn(Value, Value) -> Result<Option<Value>, HandlerError> + 'static, ) -> Handler

A synchronous 1-argument handler (state, a).

Source

pub fn sync2( f: impl Fn(Value, Value, Value) -> Result<Option<Value>, HandlerError> + 'static, ) -> Handler

A synchronous 2-argument handler (state, a, b).

Source

pub fn state1( f: impl Fn(Value, Value) -> Result<Value, HandlerError> + 'static, ) -> Handler

As Handler::sync1, but its result is the next state rather than a value to compare.

Source

pub fn async0( f: impl Fn(Value) -> Pin<Box<dyn Future<Output = HandlerReturn>>> + 'static, ) -> Handler

An asynchronous 0-argument handler returning a Future.

Source

pub fn sync_var( f: impl Fn(Value, Vec<Value>) -> Result<Option<Value>, HandlerError> + 'static, ) -> Handler

A synchronous handler of any arity: (state, args).

Source

pub fn async_var( f: impl Fn(Value, Vec<Value>) -> Pin<Box<dyn Future<Output = HandlerReturn>>> + 'static, ) -> Handler

As Handler::sync_var, returning a Future.

Trait Implementations§

Source§

impl Clone for Handler

Source§

fn clone(&self) -> Handler

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.