pub struct OptionLayer<L> { /* private fields */ }Available on crate feature
util only.Expand description
A Layer that optionally applies an inner layer L.
This is the layer produced by option_layer. When the inner layer is
present, the resulting service is the layered service; when it is absent,
the resulting service is the unmodified service.
Unlike branching with Either directly, OptionLayer unifies the error
types of the two branches to BoxError. This means the optional layer is
allowed to change the error type (as TimeoutLayer does, for example)
without the two branches needing to share an error type.
Implementations§
Source§impl<L> OptionLayer<L>
impl<L> OptionLayer<L>
Sourcepub const fn new(layer: Option<L>) -> Self
pub const fn new(layer: Option<L>) -> Self
Create a new OptionLayer wrapping the given optional layer.
Trait Implementations§
Source§impl<L: Clone> Clone for OptionLayer<L>
impl<L: Clone> Clone for OptionLayer<L>
Source§fn clone(&self) -> OptionLayer<L>
fn clone(&self) -> OptionLayer<L>
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreimpl<L: Copy> Copy for OptionLayer<L>
Source§impl<L: Debug> Debug for OptionLayer<L>
impl<L: Debug> Debug for OptionLayer<L>
Source§impl<L> From<Option<L>> for OptionLayer<L>
impl<L> From<Option<L>> for OptionLayer<L>
Source§impl<S, L> Layer<S> for OptionLayer<L>where
L: Layer<S>,
impl<S, L> Layer<S> for OptionLayer<L>where
L: Layer<S>,
Auto Trait Implementations§
impl<L> Freeze for OptionLayer<L>where
L: Freeze,
impl<L> RefUnwindSafe for OptionLayer<L>where
L: RefUnwindSafe,
impl<L> Send for OptionLayer<L>where
L: Send,
impl<L> Sync for OptionLayer<L>where
L: Sync,
impl<L> Unpin for OptionLayer<L>where
L: Unpin,
impl<L> UnsafeUnpin for OptionLayer<L>where
L: UnsafeUnpin,
impl<L> UnwindSafe for OptionLayer<L>where
L: UnwindSafe,
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
Mutably borrows from an owned value. Read more