Skip to main content

Router

Struct Router 

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

I/O-agnostic splice router keyed by envelope channel.

Channel 0 is reserved for subc itself and is always dispatched to the dedicated control handler. Other channels must be explicitly registered. Unknown client-originated non-zero channels are translated to canonical JSON ERROR frames on the connection sink so the peer can continue using the same socket. Module-originated frames for released route channels are logged and dropped as the channel-gone race backstop.

DATA-PLANE BODIES ARE NEVER DECODED HERE, and the consequence is worth stating because it looks like a guarantee and is not. Additive fields in a request or response body reach the far side untouched — not because anything permits them, but because routing reads only the 21-byte header and treats the body as opaque bytes. That is a performance property, so nothing prevents it from changing: a future reason to inspect a body would convert a wire-transparent path into a filtering one, and nobody would think of it as a contract change.

So when a peer asks whether subc sees an additive field, the answer is per-path and this path’s zero means WE NEVER LOOK rather than WE LOOK AT EVERYTHING. The control plane (typed enums at the frame boundary) and the MCP gateway (envelope unwrap plus a named struct) both narrow; only this one does not.

Implementations§

Source§

impl Router

Source

pub fn with_control_handler(control: Arc<ControlHandler>) -> Self

Source

pub fn with_default_self_handler() -> Self

Source

pub fn forwarding(&self) -> Arc<ForwardingTable> ⓘ

Source

pub fn register_backend( &mut self, channel: u16, backend: impl Into<Backend>, ) -> Result<(), RouterError>

Source

pub fn begin_connection(&self) -> RouterConnection

Source

pub async fn route_for_connection( &self, ctx: &RouteCtx, frame: Frame, ) -> Result<(), RouterError>

Trait Implementations§

Source§

impl Default for Router

Source§

fn default() -> Self

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

Auto Trait Implementations§

§

impl !Freeze for Router

§

impl !RefUnwindSafe for Router

§

impl !UnwindSafe for Router

§

impl Send for Router

§

impl Sync for Router

§

impl Unpin for Router

§

impl UnsafeUnpin for Router

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

Source§

type Output = T

Should always be Self
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.
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