pub struct SharedServerProtocol(/* private fields */);Expand description
Shared, erased server protocol selected by routing.
Wraps one of the routing kinds — metadata_routed or
body_routed — or a routing-less serde handle
(serde_only). The kind decides which
SharedProtocolRouter variant
is constructed and whether the protocol can answer the
event-stream question; everything after routing works through the ServerProtocol this
dereferences to. The kind stays private: the constructors’ trait bounds are what guarantee
each variant builds the matching router, so nothing else may assemble one.
Implementations§
Sourcepub fn get_from_request<B>(request: &Request<B>) -> Option<&Self>
pub fn get_from_request<B>(request: &Request<B>) -> Option<&Self>
Borrows the protocol selected for this request from its extensions.
Reads the protocol through SelectedOperation::get_from_request.
Returns None if no selection is stored, including before schema routing runs.
Sourcepub fn metadata_routed(protocol: impl MetadataRoutedProtocol) -> Self
pub fn metadata_routed(protocol: impl MetadataRoutedProtocol) -> Self
Wraps a protocol that selects operations from request metadata alone.
Sourcepub fn body_routed(protocol: impl BodyRoutedProtocol) -> Self
pub fn body_routed(protocol: impl BodyRoutedProtocol) -> Self
Wraps a protocol that reads the request body to select operations.
A body-routed protocol cannot express event-stream framing — the subtrait has no such
method — so this handle always answers None from Self::event_stream_framing.
Sourcepub fn serde_only(protocol: impl ServerProtocol) -> Self
pub fn serde_only(protocol: impl ServerProtocol) -> Self
Wraps a protocol for serialization only, without routing or event-stream support.
For handles that never route: middleware serializing through a hand-built protocol, and tests. Registration requires one of the routed constructors, so this handle is never asked to build a router.
Sourcepub fn event_stream_framing(&self) -> Option<EventStreamFraming<'_>>
pub fn event_stream_framing(&self) -> Option<EventStreamFraming<'_>>
Event-frame support, when this protocol supports event streams.
Only a metadata-routed protocol can answer: the BodyRoutedProtocol subtrait has no
framing method (an event-stream body must not be collected), and a serde-only handle
never routes.
Trait Implementations§
Source§fn clone(&self) -> SharedServerProtocol
fn clone(&self) -> SharedServerProtocol
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more