Skip to main content

Router

Struct Router 

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

Reply message router

Reply message router that accepts registration of route handlers and dispatches reply messages to the appropriate handler.

Implementations§

Source§

impl Router

Source

pub const DEFAULT_RESOURCE_FUNC: &'static str = "processReply"

Default resource function name

Source

pub fn new(routes: Option<Vec<Route>>) -> Self

Initialize Router instance with optional list of existing routes

Source

pub fn add_route( &mut self, route_template: &str, resource: Box<dyn RouteResource>, suffix: Option<String>, ) -> Result<(), KERIError>

Add a route between a route template and a resource

§Parameters
  • route_template - A route template to use for the resource
  • resource - The resource instance to associate with the route template
  • suffix - Optional responder name suffix for this route. If a suffix is provided, Router will map reply routes to processReply{suffix}(). In this way, multiple closely-related routes can be mapped to the same resource.
Source

pub fn dispatch( &self, serder: &SerderKERI, saider: &Saider, cigars: Option<&[Siger]>, tsgs: Option<&[(Prefixer, Seqner, Saider, Vec<Siger>)]>, ) -> Result<(), KERIError>

Dispatch a reply message to the appropriate route handler

§Parameters
  • serder - The reply message serder
  • saider - The SAID of the reply message
  • cigars - Optional non-transferable signature instances
  • tsgs - Optional transferable signature groups
Source

pub fn route_count(&self) -> usize

Get the number of registered routes

Source

pub fn has_route(&self, route: &str) -> bool

Check if a route is registered

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.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> Same for T

Source§

type Output = T

Should always be Self
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.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more