pub trait MetadataRoutedProtocol: ServerProtocol + Sized {
// Required methods
fn from_build_context(
ctx: &ProtocolBuildContext<'_>,
) -> Result<Self, RouterBuildError>;
fn build_router(
&self,
ctx: RouterBuildContext<'_>,
) -> Result<impl MetadataProtocolRouter + 'static + use<Self>, RouterBuildError>;
// Provided method
fn event_stream_framing(&self) -> Option<EventStreamFraming<'_>> { ... }
}Expand description
A ServerProtocol that selects operations from request metadata alone.
Registered with ProtocolRegistration::metadata_routed; the registry calls
from_build_context only for services whose schema declares the
registered protocol trait, and the routing service calls
build_router once per service. Only a metadata-routed protocol may
support event streams: routing never collects the body, so an event-stream body is never
read before its operation is known.
Required Methods§
Sourcefn from_build_context(
ctx: &ProtocolBuildContext<'_>,
) -> Result<Self, RouterBuildError>
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.
Sourcefn build_router(
&self,
ctx: RouterBuildContext<'_>,
) -> Result<impl MetadataProtocolRouter + 'static + use<Self>, RouterBuildError>
fn build_router( &self, ctx: RouterBuildContext<'_>, ) -> Result<impl MetadataProtocolRouter + 'static + use<Self>, RouterBuildError>
Builds operation routing once for this service.
The context carries the protocol’s own settings section next to the server-global
configuration; invalid settings are rejected with
RouterBuildError::Configuration, failing the service build.
use<Self> pins down the capture contract: the returned router owns its state and
borrows nothing from the protocol or the context, so a caller may build a router from
a temporary protocol. Implementations write use<> in their return type.
Provided Methods§
Sourcefn event_stream_framing(&self) -> Option<EventStreamFraming<'_>>
fn event_stream_framing(&self) -> Option<EventStreamFraming<'_>>
Event-frame support, when this protocol supports event streams.
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.