Skip to main content

RouterBuilder

Struct RouterBuilder 

Source
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

Source

pub fn new() -> Self

Create a new router builder

Source

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
Source

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 (as Arc<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())
Source

pub fn build(self) -> Router

Build the router

Consumes the builder and returns a configured Router.

Source

pub fn route_count(&self) -> usize

Get the number of routes that will be created

Trait Implementations§

Source§

impl Default for RouterBuilder

Source§

fn default() -> Self

Returns the “default value” for a 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 = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

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.