Skip to main content

SmPool

Struct SmPool 

Source
pub struct SmPool<S> { /* private fields */ }
Expand description

A storage-generic pool of state machines.

Arrays, mutable slices, and allocation-backed containers can all be used as storage. Dispatch is supplied as a closure because each generated sml.rs machine has its own concrete event and error types.

Implementations§

Source§

impl<S> SmPool<S>

Source

pub const fn new(storage: S) -> Self

Wraps caller-provided storage.

Source

pub fn storage(&self) -> &S

Returns the underlying storage.

Source

pub fn storage_mut(&mut self) -> &mut S

Returns the underlying storage mutably.

Source

pub fn reset<M, F>(&mut self, initialize: F)
where S: AsMut<[M]>, F: FnMut(usize) -> M,

Replaces every machine using a caller-provided initializer.

Source

pub fn process_indexed<M, E, R, F>( &mut self, index: usize, event: E, dispatch: F, ) -> Option<R>
where S: AsMut<[M]>, F: FnOnce(&mut M, E) -> R,

Dispatches one event to one machine.

Source

pub fn process_indexed_batch<M, E, I, F>( &mut self, indices: I, event: E, dispatch: F, ) -> usize
where S: AsMut<[M]>, E: Clone, I: IntoIterator<Item = usize>, F: FnMut(&mut M, E),

Dispatches the same clonable event to a batch of machine indices.

Returns the number of valid indices that were processed.

Source

pub fn process_event_batch<M, E, I, F>( &mut self, events: I, dispatch: F, ) -> usize
where S: AsMut<[M]>, I: IntoIterator<Item = IndexedEvent<E>>, F: FnMut(&mut M, E),

Dispatches a batch of indexed events.

Returns the number of valid indices that were processed.

Auto Trait Implementations§

§

impl<S> Freeze for SmPool<S>
where S: Freeze,

§

impl<S> RefUnwindSafe for SmPool<S>
where S: RefUnwindSafe,

§

impl<S> Send for SmPool<S>
where S: Send,

§

impl<S> Sync for SmPool<S>
where S: Sync,

§

impl<S> Unpin for SmPool<S>
where S: Unpin,

§

impl<S> UnsafeUnpin for SmPool<S>
where S: UnsafeUnpin,

§

impl<S> UnwindSafe for SmPool<S>
where S: UnwindSafe,

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.