Struct SeriesBuilder

Source
pub struct SeriesBuilder<'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>>> {
  SeriesBuilder::new_without_default_action(SimpleStateImplementation::new('x'))
  .next_state(char_matcher('a'), SimpleStateImplementation::new('a'))
  .next_state(char_matcher('b'), SimpleStateImplementation::new('b'))
  .next_state(char_matcher('c'), SimpleStateImplementation::new('c'))
  .build()
}

Implementations§

Source§

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

Source

pub fn new_without_default_action( root: SimpleStateImplementation<'a, K, Id, D, E>, ) -> SeriesBuilder<'a, K, Id, D, E>

Source

pub fn new<FDExec: Fn(&mut D, &K) -> Result<(), E> + 'a>( root: SimpleStateImplementation<'a, K, Id, D, E>, default_execution_function: FDExec, ) -> SeriesBuilder<'a, K, Id, D, E>

Source

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

Creates new shared simple state and adds new connection to last added state with given matcher.

Source

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

WARNING: Passed state will be modified after creating next connection, even before build() is called. Use with caution. Creates connection from last appended state to specified state.

Source

pub fn build(self) -> SharedSimpleState<'a, K, Id, D, E>

Consumes builder and returns root state.

Auto Trait Implementations§

§

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

§

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

§

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

§

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

§

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

§

impl<'a, K, Id, D, E> !UnwindSafe for SeriesBuilder<'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.