pub struct UpgradeLayer<O> { /* private fields */ }Expand description
UpgradeLayer is a middleware that can be used to upgrade a request.
See UpgradeService for more details.
Implementations§
Source§impl<O> UpgradeLayer<O>
impl<O> UpgradeLayer<O>
Sourcepub fn new<M, R, H>(
exec: Executor,
matcher: M,
responder: R,
handler: H,
) -> Self
pub fn new<M, R, H>( exec: Executor, matcher: M, responder: R, handler: H, ) -> Self
Create a new upgrade layer whose handler’s errors are routed to the
default ErrorSink (TracingErrorSink::default, DEBUG level).
Use UpgradeLayer::new_with_error_sink to give the handler a custom
sink (which also lifts the Error: Into<BoxError> requirement, allowing
any handler error type).
Sourcepub fn new_with_error_sink<M, R, H, Sink>(
exec: Executor,
matcher: M,
responder: R,
handler: H,
sink: Sink,
) -> Self
pub fn new_with_error_sink<M, R, H, Sink>( exec: Executor, matcher: M, responder: R, handler: H, sink: Sink, ) -> Self
Create a new upgrade layer, routing the handler’s errors (of any type)
to the given ErrorSink.
Sourcepub fn new_dropping_errors<M, R, H>(
exec: Executor,
matcher: M,
responder: R,
handler: H,
) -> Self
pub fn new_dropping_errors<M, R, H>( exec: Executor, matcher: M, responder: R, handler: H, ) -> Self
Create a new upgrade layer whose handler’s errors (of any type) are
silently dropped (DropErrorSink). Use this for handlers whose errors
are neither actionable nor traceable.
Sourcepub fn on<M, R, H>(self, matcher: M, responder: R, handler: H) -> Self
pub fn on<M, R, H>(self, matcher: M, responder: R, handler: H) -> Self
Add an extra upgrade handler, routing its errors to the default
ErrorSink (TracingErrorSink::default, DEBUG level).
Sourcepub fn on_dropping_errors<M, R, H>(
self,
matcher: M,
responder: R,
handler: H,
) -> Self
pub fn on_dropping_errors<M, R, H>( self, matcher: M, responder: R, handler: H, ) -> Self
Add an extra upgrade handler whose errors (of any type) are silently
dropped (DropErrorSink).
Sourcepub fn on_with_error_sink<M, R, H, Sink>(
self,
matcher: M,
responder: R,
handler: H,
sink: Sink,
) -> Self
pub fn on_with_error_sink<M, R, H, Sink>( self, matcher: M, responder: R, handler: H, sink: Sink, ) -> Self
Add an extra upgrade handler, routing its errors (of any type) to the
given ErrorSink.
Sourcepub fn with_upgrade_error_sink(self, sink: impl ErrorSink) -> Self
pub fn with_upgrade_error_sink(self, sink: impl ErrorSink) -> Self
Set the ErrorSink used for errors that occur while establishing
the upgraded connection (i.e. the HTTP upgrade itself fails, before any
handler runs). Per-handler errors are routed to their own sink instead;
see UpgradeLayer::on_with_error_sink.
Defaults to TracingErrorSink::default (traces at DEBUG level).
Trait Implementations§
Source§impl<O> Clone for UpgradeLayer<O>
impl<O> Clone for UpgradeLayer<O>
Source§impl<O> Debug for UpgradeLayer<O>
impl<O> Debug for UpgradeLayer<O>
Source§impl<S, O> Layer<S> for UpgradeLayer<O>
impl<S, O> Layer<S> for UpgradeLayer<O>
Source§type Service = UpgradeService<S, O>
type Service = UpgradeService<S, O>
Source§fn layer(&self, inner: S) -> Self::Service
fn layer(&self, inner: S) -> Self::Service
Source§fn into_layer(self, inner: S) -> Self::Service
fn into_layer(self, inner: S) -> Self::Service
layer but consuming self after the service was created. Read moreAuto Trait Implementations§
impl<O> !RefUnwindSafe for UpgradeLayer<O>
impl<O> !UnwindSafe for UpgradeLayer<O>
impl<O> Freeze for UpgradeLayer<O>
impl<O> Send for UpgradeLayer<O>
impl<O> Sync for UpgradeLayer<O>
impl<O> Unpin for UpgradeLayer<O>
impl<O> UnsafeUnpin for UpgradeLayer<O>
Blanket Implementations§
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> FutureExt for T
impl<T> FutureExt for T
Source§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
Source§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§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