Skip to main content

SharedServerProtocol

Struct SharedServerProtocol 

Source
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§

Source§

impl SharedServerProtocol

Source

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.

Source

pub fn metadata_routed(protocol: impl MetadataRoutedProtocol) -> Self

Wraps a protocol that selects operations from request metadata alone.

Source

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.

Source

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.

Source

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§

impl Clone for SharedServerProtocol

Source§

fn clone(&self) -> SharedServerProtocol

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for SharedServerProtocol

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Deref for SharedServerProtocol

Source§

type Target = dyn ServerProtocol

The resulting type after dereferencing.
Source§

fn deref(&self) -> &Self::Target

Dereferences the value.

Auto Trait Implementations§

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

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

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
§

impl<Unshared, Shared> IntoShared<Shared> for Unshared
where Shared: FromUnshared<Unshared>,

§

fn into_shared(self) -> Shared

Creates a shared type from an unshared type.
Source§

impl<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

Source§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.
§

impl<T> WithSubscriber for T

§

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
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,