Skip to main content

BodyRoutedProtocol

Trait BodyRoutedProtocol 

Source
pub trait BodyRoutedProtocol: ServerProtocol + Sized {
    // Required methods
    fn from_build_context(
        ctx: &ProtocolBuildContext<'_>,
    ) -> Result<Self, RouterBuildError>;
    fn build_router(
        &self,
        ctx: RouterBuildContext<'_>,
    ) -> Result<impl BodyProtocolRouter + 'static + use<Self>, RouterBuildError>;
}
Expand description

A ServerProtocol that reads the request body to select operations.

Registered with ProtocolRegistration::body_routed. Claiming is head-first; the router escalates to body bytes by returning a requirement the routing service satisfies — the service owns all body I/O, the protocol owns interpretation. The protocol is handed only the service’s non-streaming operations — see BodyProtocolRouter. Event-stream framing is not expressible here: the subtrait has no such method, so the conflict between body-based routing and serving event-stream bodies cannot arise. Metadata routers can recognize streaming inputs so claims requiring body bytes can be skipped.

Required Methods§

Source

fn from_build_context( ctx: &ProtocolBuildContext<'_>, ) -> Result<Self, RouterBuildError>

Builds this protocol for a service, from its registered configuration. Invalid configuration fails the service build.

Source

fn build_router( &self, ctx: RouterBuildContext<'_>, ) -> Result<impl BodyProtocolRouter + 'static + use<Self>, RouterBuildError>

Builds operation routing once for this service, over the service’s non-streaming operations.

use<Self> pins down the capture contract exactly as on MetadataRoutedProtocol::build_router; implementations write use<>.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§