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
impl MultiProtocolRoutingServiceBuilder
Sourcepub fn new(service: &'static ServiceSchema<'static>) -> Self
pub fn new(service: &'static ServiceSchema<'static>) -> Self
Starts configuring routing for the supplied schema.
Sourcepub 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
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.
Sourcepub 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
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>
impl<L> MultiProtocolRoutingServiceBuilder<L>
Sourcepub fn registries(
self,
registries: impl IntoIterator<Item = &'static ProtocolRegistry>,
) -> Self
pub fn registries( self, registries: impl IntoIterator<Item = &'static ProtocolRegistry>, ) -> Self
Replaces the external registries. ProtocolRegistry::BUILTIN is always consulted.
Sourcepub fn operation_handler_bindings(
self,
bindings: impl IntoIterator<Item = (&'static OperationSchema<'static>, SyncRoute<RequestBody>)>,
) -> Self
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.
Sourcepub fn options(self, options: ProtocolOptions) -> Self
pub fn options(self, options: ProtocolOptions) -> Self
Replaces the protocol options.
Sourcepub fn layer<N>(self, layer: N) -> MultiProtocolRoutingServiceBuilder<N>
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.
Sourcepub 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,
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§
Auto Trait Implementations§
impl<L> Freeze for MultiProtocolRoutingServiceBuilder<L>where
L: Freeze,
impl<L = Identity> !RefUnwindSafe for MultiProtocolRoutingServiceBuilder<L>
impl<L> Send for MultiProtocolRoutingServiceBuilder<L>where
L: Send,
impl<L> Sync for MultiProtocolRoutingServiceBuilder<L>where
L: Sync,
impl<L> Unpin for MultiProtocolRoutingServiceBuilder<L>where
L: Unpin,
impl<L> UnsafeUnpin for MultiProtocolRoutingServiceBuilder<L>where
L: UnsafeUnpin,
impl<L = Identity> !UnwindSafe for MultiProtocolRoutingServiceBuilder<L>
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
§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