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>
impl<'a, K, Id: Copy, D: KeyProvidingData<K>, E> SeriesDefiner<'a, K, Id, D, E>
Sourcepub fn new_without_default_action(
starting_state: &SharedSimpleState<'a, K, Id, D, E>,
) -> SeriesDefiner<'a, K, Id, D, E>
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.
Sourcepub 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>
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.
Sourcepub 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>
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.
Sourcepub fn next_state<M>(
self,
matcher: M,
next_state: &SharedSimpleState<'a, K, Id, D, E>,
) -> SeriesDefiner<'a, K, Id, D, E>
pub fn next_state<M>( self, matcher: M, next_state: &SharedSimpleState<'a, K, Id, D, E>, ) -> SeriesDefiner<'a, K, Id, D, E>
Adds connection to currently processed state. No function is executed when changing state. Creates a default connection to starting state as well.
Sourcepub 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>
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>
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> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more