Struct SeriesDefiner

Source
pub struct SeriesDefiner<'a, K, Id: Copy, D: KeyProvidingData<K>, E> { /* private fields */ }
Expand description

Allows for quick definition of chain of states that follow single path.

§Examples

// Creates series of state that will match 'abc' character sequence or go back to root state anytime there is a mismatch.
fn create_abc_series_state_tree() -> Rc<RefCell<dyn AutomatonState<'static, char, TestData, String>>> {
  let root_state = new_shared_concrete_state(SimpleStateImplementation::new('x'));
  SeriesDefiner::new_without_default_action(&root_state)
  .next_state(char_matcher('a'), &new_shared_concrete_state(SimpleStateImplementation::new('a')))
  .next_state(char_matcher('b'), &new_shared_concrete_state(SimpleStateImplementation::new('b')))
  .next_state(char_matcher('c'), &new_shared_concrete_state(SimpleStateImplementation::new('c')));
  root_state
}

Implementations§

Source§

impl<'a, K, Id: Copy, D: KeyProvidingData<K>, E> SeriesDefiner<'a, K, Id, D, E>

Source

pub fn new_without_default_action( starting_state: &SharedSimpleState<'a, K, Id, D, E>, ) -> SeriesDefiner<'a, K, Id, D, E>

Creates new SeriesDefiner which defaults unmatched connections to the same node it starts from.

Source

pub fn new<FDExec: Fn(&mut D, &K) -> Result<(), E> + 'a>( starting_state: &SharedSimpleState<'a, K, Id, D, E>, default_execution_function: FDExec, ) -> SeriesDefiner<'a, K, Id, D, E>

Creates new SeriesDefiner which defaults unmatched connections to the same node it starts from.

Source

pub fn new_different_default_state<FDExec: Fn(&mut D, &K) -> Result<(), E> + 'a>( starting_state: &SharedSimpleState<'a, K, Id, D, E>, default_state: &SharedSimpleState<'a, K, Id, D, E>, default_execution_function: FDExec, ) -> SeriesDefiner<'a, K, Id, D, E>

Creates new SeriesDefiner with possible different starting and default states.

Source

pub fn next_state<M>( self, matcher: M, next_state: &SharedSimpleState<'a, K, Id, D, E>, ) -> SeriesDefiner<'a, K, Id, D, E>
where M: 'a + Fn(&K) -> bool,

Adds connection to currently processed state. No function is executed when changing state. Creates a default connection to starting state as well.

Source

pub fn next_state_exec<M, FExec>( self, matcher: M, next_state: &SharedSimpleState<'a, K, Id, D, E>, execution_function: FExec, ) -> SeriesDefiner<'a, K, Id, D, E>
where M: 'a + Fn(&K) -> bool, FExec: 'a + Fn(&mut D, &K) -> Result<(), E>,

Adds connection to currently processed state. Given function is executed when changing state. Creates a default connection to starting state as well.

Auto Trait Implementations§

§

impl<'a, K, Id, D, E> Freeze for SeriesDefiner<'a, K, Id, D, E>

§

impl<'a, K, Id, D, E> !RefUnwindSafe for SeriesDefiner<'a, K, Id, D, E>

§

impl<'a, K, Id, D, E> !Send for SeriesDefiner<'a, K, Id, D, E>

§

impl<'a, K, Id, D, E> !Sync for SeriesDefiner<'a, K, Id, D, E>

§

impl<'a, K, Id, D, E> Unpin for SeriesDefiner<'a, K, Id, D, E>

§

impl<'a, K, Id, D, E> !UnwindSafe for SeriesDefiner<'a, K, Id, D, E>

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.