BTreeKVRouter

Struct BTreeKVRouter 

Source
pub struct BTreeKVRouter<Key, Value, RouteAccepts, Fallback = ()> { /* private fields */ }
Expand description

Routes (Key, Value) pairs to acceptors stored in a BTreeMap.

If no route exists for the provided key, the fallback acceptor receives the original pair. Downstream acceptors also receive the original (Key, Value) so they can keep using the key.

Implementations§

Source§

impl<Key, Value, RouteAccepts> BTreeKVRouter<Key, Value, RouteAccepts, ()>

Source

pub fn new(routes: BTreeMap<Key, RouteAccepts>) -> Self

Creates a BTreeKVRouter that drops pairs when no route matches.

Source§

impl<Key, Value, RouteAccepts, Fallback> BTreeKVRouter<Key, Value, RouteAccepts, Fallback>

Source

pub fn with_fallback( routes: BTreeMap<Key, RouteAccepts>, fallback: Fallback, ) -> Self

Creates a BTreeKVRouter with a custom fallback acceptor.

Source

pub fn routes(&self) -> &BTreeMap<Key, RouteAccepts>

Source

pub fn routes_mut(&mut self) -> &mut BTreeMap<Key, RouteAccepts>

Source

pub fn fallback(&self) -> &Fallback

Source

pub fn fallback_mut(&mut self) -> &mut Fallback

Trait Implementations§

Source§

impl<Key, Value, RouteAccepts, Fallback> Accepts<(Key, Value)> for BTreeKVRouter<Key, Value, RouteAccepts, Fallback>
where Key: Ord, RouteAccepts: Accepts<(Key, Value)>, Fallback: Accepts<(Key, Value)>,

Source§

fn accept(&self, pair: (Key, Value))

Source§

impl<Key, Value, RouteAccepts, Fallback> AsyncAccepts<(Key, Value)> for BTreeKVRouter<Key, Value, RouteAccepts, Fallback>
where Key: Ord, RouteAccepts: AsyncAccepts<(Key, Value)>, Fallback: AsyncAccepts<(Key, Value)>,

Source§

fn accept_async<'a>( &'a self, pair: (Key, Value), ) -> impl Future<Output = ()> + 'a
where Key: 'a, Value: 'a,

Source§

impl<Key: Clone, Value: Clone, RouteAccepts: Clone, Fallback: Clone> Clone for BTreeKVRouter<Key, Value, RouteAccepts, Fallback>

Source§

fn clone(&self) -> BTreeKVRouter<Key, Value, RouteAccepts, Fallback>

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<Key: Debug, Value: Debug, RouteAccepts: Debug, Fallback: Debug> Debug for BTreeKVRouter<Key, Value, RouteAccepts, Fallback>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<Key, Value, RouteAccepts, Fallback> Freeze for BTreeKVRouter<Key, Value, RouteAccepts, Fallback>
where Fallback: Freeze,

§

impl<Key, Value, RouteAccepts, Fallback> RefUnwindSafe for BTreeKVRouter<Key, Value, RouteAccepts, Fallback>
where Fallback: RefUnwindSafe, Value: RefUnwindSafe, Key: RefUnwindSafe, RouteAccepts: RefUnwindSafe,

§

impl<Key, Value, RouteAccepts, Fallback> Send for BTreeKVRouter<Key, Value, RouteAccepts, Fallback>
where Fallback: Send, Value: Send, Key: Send, RouteAccepts: Send,

§

impl<Key, Value, RouteAccepts, Fallback> Sync for BTreeKVRouter<Key, Value, RouteAccepts, Fallback>
where Fallback: Sync, Value: Sync, Key: Sync, RouteAccepts: Sync,

§

impl<Key, Value, RouteAccepts, Fallback> Unpin for BTreeKVRouter<Key, Value, RouteAccepts, Fallback>
where Fallback: Unpin, Value: Unpin,

§

impl<Key, Value, RouteAccepts, Fallback> UnwindSafe for BTreeKVRouter<Key, Value, RouteAccepts, Fallback>
where Fallback: UnwindSafe, Key: RefUnwindSafe, RouteAccepts: RefUnwindSafe, Value: 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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.