RouterController

Struct RouterController 

Source
pub struct RouterController { /* private fields */ }
Expand description

Reactive navigation controller for one shard tree.

Implementations§

Source§

impl RouterController

Source

pub fn new() -> Self

Create an empty controller.

Source

pub fn with_root(root_dest: impl RouterDestination + 'static) -> Self

Create a controller seeded with a root destination.

Source

pub fn with_root_shared(root_dest: Arc<dyn RouterDestination>) -> Self

Create a controller seeded with a shared root destination.

Source

pub fn version(&self) -> u64

Monotonic routing version.

Source

pub fn push<T: RouterDestination + 'static>(&mut self, destination: T)

Push a destination onto the stack.

Source

pub fn push_shared(&mut self, destination: Arc<dyn RouterDestination>)

Push a shared destination onto the stack.

Source

pub fn pop(&mut self) -> Option<Arc<dyn RouterDestination>>

Pop the top destination from the stack.

Returns None if the stack is empty.

Source

pub fn replace<T: RouterDestination + 'static>( &mut self, destination: T, ) -> Option<Arc<dyn RouterDestination>>

Replace the top destination.

If the stack is empty, this behaves like Self::push.

Source

pub fn replace_shared( &mut self, destination: Arc<dyn RouterDestination>, ) -> Option<Arc<dyn RouterDestination>>

Replace the top destination with a shared destination.

Source

pub fn is_empty(&self) -> bool

Whether the stack is empty.

Source

pub fn len(&self) -> usize

Number of destinations in the stack.

Source

pub fn last(&self) -> Option<&dyn RouterDestination>

Top destination.

Source

pub fn exec_current(&self) -> bool

Execute the top destination.

Returns false when the stack is empty.

Source

pub fn init_or_get<T, F, R>(&self, id: &str, f: F) -> R
where T: Default + Send + Sync + 'static, F: FnOnce(ShardState<T>) -> R,

Get or initialize route-scoped state and provide it to f.

Source

pub fn init_or_get_with_lifecycle<T, F, R>( &self, id: &str, life_cycle: ShardStateLifeCycle, f: F, ) -> R
where T: Default + Send + Sync + 'static, F: FnOnce(ShardState<T>) -> R,

Get or initialize state for a lifecycle scope and provide it to f.

Source

pub fn clear(&mut self)

Clear all destinations from the stack.

Source

pub fn reset(&mut self, root_dest: impl RouterDestination + 'static)

Clear all destinations and push a new root destination.

Source

pub fn reset_shared(&mut self, root_dest: Arc<dyn RouterDestination>)

Clear all destinations and push a shared root destination.

Trait Implementations§

Source§

impl Default for RouterController

Source§

fn default() -> Self

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

impl Drop for RouterController

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more

Auto Trait Implementations§

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.