Skip to main content

Dispatcher

Struct Dispatcher 

Source
pub struct Dispatcher<V, C, O>
where V: TypedDispatcher,
{ /* private fields */ }
Expand description

Unsealed dispatcher builder. Register helpers per variant kind, then call into_sealed() to prove coverage.

Implementations§

Source§

impl<V, C, O> Dispatcher<V, C, O>
where V: TypedDispatcher,

Source

pub fn new() -> Self

Start a fresh dispatcher with the default OverrideLast merge strategy.

Source

pub fn with_strategy(self, strategy: MergeStrategy) -> Self

Override the merge strategy used by apply when folding per-variant overrides. Defaults to OverrideLast.

Source

pub fn helper<F>(self, kind: &str, f: F) -> Result<Self, DispatcherError>
where F: Fn(&V, &mut C) -> O + Send + Sync + 'static,

Register a helper for a kind. Returns DuplicateHelper if the kind already has one — pleme-io’s typed-dispatch rule is: one kind, one helper.

§Errors

Returns DispatcherError::DuplicateHelper if a helper for kind has already been registered.

Source

pub fn with_helper<F>(self, kind: &str, f: F) -> Self
where F: Fn(&V, &mut C) -> O + Send + Sync + 'static,

Convenience: register a helper, panic on duplicate. Use only when you control both sides of the registration and want builder-style ergonomics.

Source

pub fn into_sealed(self) -> Result<SealedDispatcher<V, C, O>, DispatcherError>

Seal the dispatcher — asserts every kind in V::variant_kinds() has a registered helper. Returns a SealedDispatcher that can apply variants without runtime coverage checks.

§Errors

Returns DispatcherError::MissingCoverage if any kind in the variant universe has no registered helper.

Trait Implementations§

Source§

impl<V, C, O> Default for Dispatcher<V, C, O>
where V: TypedDispatcher,

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl<V, C, O> !RefUnwindSafe for Dispatcher<V, C, O>

§

impl<V, C, O> !UnwindSafe for Dispatcher<V, C, O>

§

impl<V, C, O> Freeze for Dispatcher<V, C, O>

§

impl<V, C, O> Send for Dispatcher<V, C, O>

§

impl<V, C, O> Sync for Dispatcher<V, C, O>

§

impl<V, C, O> Unpin for Dispatcher<V, C, O>

§

impl<V, C, O> UnsafeUnpin for Dispatcher<V, C, O>

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> 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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.