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
impl Router
Sourcepub const DEFAULT_RESOURCE_FUNC: &'static str = "processReply"
pub const DEFAULT_RESOURCE_FUNC: &'static str = "processReply"
Default resource function name
Sourcepub fn new(routes: Option<Vec<Route>>) -> Self
pub fn new(routes: Option<Vec<Route>>) -> Self
Initialize Router instance with optional list of existing routes
Sourcepub fn add_route(
&mut self,
route_template: &str,
resource: Box<dyn RouteResource>,
suffix: Option<String>,
) -> Result<(), KERIError>
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 resourceresource- The resource instance to associate with the route templatesuffix- 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.
Sourcepub fn dispatch(
&self,
serder: &SerderKERI,
saider: &Saider,
cigars: Option<&[Siger]>,
tsgs: Option<&[(Prefixer, Seqner, Saider, Vec<Siger>)]>,
) -> Result<(), KERIError>
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 serdersaider- The SAID of the reply messagecigars- Optional non-transferable signature instancestsgs- Optional transferable signature groups
Sourcepub fn route_count(&self) -> usize
pub fn route_count(&self) -> usize
Get the number of registered routes
Auto Trait Implementations§
impl !RefUnwindSafe for Router
impl !UnwindSafe for Router
impl Freeze for Router
impl Send for Router
impl Sync for Router
impl Unpin for Router
impl UnsafeUnpin for Router
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