pub struct RouterBuilder { /* private fields */ }Expand description
Builder for constructing routers
Provides a fluent API for adding routes before creating the router.
Implementations§
Source§impl RouterBuilder
impl RouterBuilder
Sourcepub fn from_routes(routes: Vec<(String, IngestFn)>) -> Self
pub fn from_routes(routes: Vec<(String, IngestFn)>) -> Self
Create a router builder from a collection of routes
This is a convenience method for automatic router construction from
AimDb::collect_inbound_routes(). The resource_ids are converted to
Arc<str> for proper memory management.
§Arguments
routes- Vector of (resource_id, ingest) tuples
Sourcepub fn add_route(self, resource_id: Arc<str>, ingest: IngestFn) -> Self
pub fn add_route(self, resource_id: Arc<str>, ingest: IngestFn) -> Self
Add a route to the router
§Arguments
resource_id- Resource identifier to match (asArc<str>)ingest- Fused ingest callback (deserialize + produce)
§Resource ID Memory Management
The resource_id is stored as Arc<str> for proper reference counting and cleanup.
You can create an Arc<str> from:
- String literal:
Arc::from("sensors/temperature") - Owned String:
Arc::from(string.as_str())
Sourcepub fn build(self) -> Router
pub fn build(self) -> Router
Build the router
Consumes the builder and returns a configured Router.
Sourcepub fn route_count(&self) -> usize
pub fn route_count(&self) -> usize
Get the number of routes that will be created
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for RouterBuilder
impl !UnwindSafe for RouterBuilder
impl Freeze for RouterBuilder
impl Send for RouterBuilder
impl Sync for RouterBuilder
impl Unpin for RouterBuilder
impl UnsafeUnpin for RouterBuilder
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