pub struct AgentRouter { /* private fields */ }Expand description
Engine that routes inbound messages to agent instances.
Created from an AgentRoutingConfig loaded from clawft.toml.
Routes are evaluated in order; first match wins.
Implementations§
Source§impl AgentRouter
impl AgentRouter
Sourcepub fn new(config: AgentRoutingConfig) -> Self
pub fn new(config: AgentRoutingConfig) -> Self
Create a new router from configuration.
Sourcepub fn with_catch_all(agent: impl Into<String>) -> Self
pub fn with_catch_all(agent: impl Into<String>) -> Self
Create a router with only a catch-all agent (no rules).
Sourcepub fn route(&self, msg: &InboundMessage) -> RoutingResult
pub fn route(&self, msg: &InboundMessage) -> RoutingResult
Route a message to the appropriate agent ID.
§Routing semantics
- First matching rule wins.
- Anonymous messages (empty
sender_id) are routed to the catch-all agent (if configured). - No match + no catch-all: returns
RoutingResult::NoMatchand logs a warning.
Sourcepub fn route_count(&self) -> usize
pub fn route_count(&self) -> usize
Number of configured routes.
Sourcepub fn has_catch_all(&self) -> bool
pub fn has_catch_all(&self) -> bool
Whether a catch-all agent is configured.
Auto Trait Implementations§
impl Freeze for AgentRouter
impl RefUnwindSafe for AgentRouter
impl Send for AgentRouter
impl Sync for AgentRouter
impl Unpin for AgentRouter
impl UnsafeUnpin for AgentRouter
impl UnwindSafe for AgentRouter
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
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more