Skip to main content

MetadataProtocolRouter

Trait MetadataProtocolRouter 

Source
pub trait MetadataProtocolRouter:
    Send
    + Sync
    + Debug {
    // Required methods
    fn route(
        &self,
        request: &Request<()>,
    ) -> Result<OperationTarget, RoutingError>;
    fn claim(&self, request: &Request<()>) -> RouteClaim;

    // Provided method
    fn recognizes_streaming_input(&self, _request: &Request<()>) -> bool { ... }
}
Expand description

Selects an operation from request metadata alone.

The request carries no body: metadata routing never reads one, and keeping the trait body-free keeps it usable behind dyn for every transport body type.

Rejections are the standard RoutingError, classified but not serialized: the routing service hands it to the rejecting protocol’s serialize_routing_error, which owns the kind-to-wire mapping.

Required Methods§

Source

fn route(&self, request: &Request<()>) -> Result<OperationTarget, RoutingError>

Selects from the request URI, method and headers after RouteClaim::Claimed. All routing errors after a claim are terminal.

Source

fn claim(&self, request: &Request<()>) -> RouteClaim

Decides whether the request meets this protocol’s claiming requirements.

Provided Methods§

Source

fn recognizes_streaming_input(&self, _request: &Request<()>) -> bool

Recognizes a potentially streaming input using only the request head. Output-only streaming does not qualify. This must perform no body I/O or request-head mutation. A match skips routers that need body bytes to claim; it neither claims nor rejects the request. The service consults it only when its schema declares a streaming input. Routers recognize streaming inputs belonging to their protocol, including inputs that routing will reject as unsupported, so rejection does not require body collection. The default recognizes none.

Implementors§