Skip to main content

ConditionalRouter

Struct ConditionalRouter 

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

Content-based router using regex pattern matching.

Rules are evaluated in order. The first matching pattern wins. If no pattern matches, routes to the configured default target.

Implementations§

Source§

impl ConditionalRouter

Source

pub fn new() -> Self

Create a new empty ConditionalRouter.

Source

pub fn when(self, pattern: &str, target: impl Into<AgentId>) -> Self

Add a routing rule: if message content matches pattern, route to target.

Rules are checked in insertion order. The first match wins.

§Panics

Panics if pattern is not a valid regex.

Source

pub fn default(self, target: impl Into<AgentId>) -> Self

Set the fallback target when no pattern matches.

If no default is set and no pattern matches, returns a no-op Complete("").

Trait Implementations§

Source§

impl Default for ConditionalRouter

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl Router for ConditionalRouter

Source§

fn route(&self, message: &TeamMessage, _state: &TeamState) -> RoutingDecision

Decide where to route a message given the current team state.

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> Instrument for T

Source§

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

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

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, 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.
Source§

impl<T> WithSubscriber for T

Source§

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
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

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