Skip to main content

MultiProtocolRoutingServiceBuilder

Struct MultiProtocolRoutingServiceBuilder 

Source
pub struct MultiProtocolRoutingServiceBuilder<L = Identity> { /* private fields */ }
Expand description

Collects routing inputs, validating and constructing them only in Self::build.

The service schema is required. Built-in protocols are always available; additional registries contribute protocols implemented outside this crate.

Implementations§

Source§

impl MultiProtocolRoutingServiceBuilder

Source

pub fn new(service: &'static ServiceSchema<'static>) -> Self

Starts configuring routing for the supplied schema.

Source

pub fn from_operation_handler_bindings( service: &'static ServiceSchema<'static>, registries: impl IntoIterator<Item = &'static ProtocolRegistry>, bindings: impl IntoIterator<Item = (&'static OperationSchema<'static>, SyncRoute<RequestBody>)>, ) -> Self

Collects operation bindings and external protocol registries with default options.

Source

pub fn from_operation_handler_bindings_with_options( service: &'static ServiceSchema<'static>, registries: impl IntoIterator<Item = &'static ProtocolRegistry>, bindings: impl IntoIterator<Item = (&'static OperationSchema<'static>, SyncRoute<RequestBody>)>, options: ProtocolOptions, ) -> Self

Collects operation bindings, external registries, and protocol options.

Source§

impl<L> MultiProtocolRoutingServiceBuilder<L>

Source

pub fn registries( self, registries: impl IntoIterator<Item = &'static ProtocolRegistry>, ) -> Self

Replaces the external registries. ProtocolRegistry::BUILTIN is always consulted.

Source

pub fn operation_handler_bindings( self, bindings: impl IntoIterator<Item = (&'static OperationSchema<'static>, SyncRoute<RequestBody>)>, ) -> Self

Replaces the protocol-independent (operation schema, handler route) bindings.

Source

pub fn options(self, options: ProtocolOptions) -> Self

Replaces the protocol options.

Source

pub fn layer<N>(self, layer: N) -> MultiProtocolRoutingServiceBuilder<N>

Sets the handler layer, replacing any previously configured layer.

The layer is applied during construction. It runs after routing; inspect the selection through crate::schema::SelectedOperation::get_from_request. Forwarded requests must preserve their extensions. Discarding them causes the upgrade or missing-handler fallback to return an empty 500 without reading input or invoking the handler. Routing may already have collected the input before the layer runs. Compose multiple layers with a Tower layer stack.

Source

pub fn build(self) -> Result<MultiProtocolRoutingService, RouterBuildError>
where L: Layer<SyncRoute<RequestBody>>, L::Service: Service<Request<RequestBody>, Response = Response<BoxBody>, Error = Infallible> + Clone + Send + Sync + 'static, <L::Service as Service<Request<RequestBody>>>::Future: Send + 'static,

Validates the configuration and builds protocol routers and layered handlers.

Trait Implementations§

Source§

impl<L: Debug> Debug for MultiProtocolRoutingServiceBuilder<L>

Source§

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

Formats the value using the given formatter. Read more

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> 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<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,