pub struct OptionalLayer<L>(/* private fields */);
Expand description

Optional layer. It requires that the inner layer won’t change the input and output of the input operator.

Trait Implementations§

source§

impl<L: Clone> Clone for OptionalLayer<L>

source§

fn clone(&self) -> OptionalLayer<L>

Returns a copy 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<L: Debug> Debug for OptionalLayer<L>

source§

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

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

impl<In, P, L> Layer<In, P> for OptionalLayer<L>where P: ContextOperator<In>, L: Layer<In, P>, L::Operator: ContextOperator<In, Out = P::Out>,

§

type Operator = Either<<L as Layer<In, P>>::Operator, P>

The output operator.
§

type Out = <P as ContextOperator<In>>::Out

The output type.
source§

fn layer(&self, operator: P) -> Self::Operator

Convert an In-operator to another In-operator.
source§

impl<L: Copy> Copy for OptionalLayer<L>

Auto Trait Implementations§

§

impl<L> RefUnwindSafe for OptionalLayer<L>where L: RefUnwindSafe,

§

impl<L> Send for OptionalLayer<L>where L: Send,

§

impl<L> Sync for OptionalLayer<L>where L: Sync,

§

impl<L> Unpin for OptionalLayer<L>where L: Unpin,

§

impl<L> UnwindSafe for OptionalLayer<L>where L: UnwindSafe,

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere 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.

source§

impl<T, U> Into<U> for Twhere 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<In, P, L> LayerExt<In, P> for Lwhere P: ContextOperator<In>, L: Layer<In, P>,

source§

fn boxed(self) -> BoxLayer<P, In, Self::Out>where Self: Sized + Send + Sync + 'static, Self::Operator: Send + 'static,

Create a boxed Layer.
source§

fn with<Outer>(self, outer: Outer) -> Stack<Self, Outer>where Outer: Layer<In, Self::Operator>, Self: Sized,

Stack a outer layer on top of the inner layer.
source§

fn insert_env<R, Out, F>(self, f: F) -> Stack<Self, Insert<F>>where F: Fn() -> R, R: for<'a> RefOperator<'a, In, Output = Out>, Out: Send + Sync + 'static, Self: Sized,

Add a Insert layer with the given RefOperator constructor (i.e. a function that returns a RefOperator). Read more
source§

fn insert_env_if<R, Out, F>( self, enable: bool, f: F ) -> Stack<Self, OptionalLayer<Insert<F>>>where F: Fn() -> R, R: for<'a> RefOperator<'a, In, Output = Out>, Out: Send + Sync + 'static, Self: Sized,

Optionally add the Insert layer with the given RefOperator constructor. Read more
source§

fn insert_data<R, Out, F>(self, f: F) -> Stack<Self, InsertData<F>>where F: Fn() -> R, R: for<'a> RefOperator<'a, In, Output = Option<Out>>, Out: Send + Sync + 'static, Self: Sized,

Add a InsertData layer with the given RefOperator constructor. (i.e. a function that returns a RefOperator). Read more
source§

fn insert_data_if<R, Out, F>( self, enable: bool, f: F ) -> Stack<Self, OptionalLayer<InsertData<F>>>where F: Fn() -> R, R: for<'a> RefOperator<'a, In, Output = Option<Out>>, Out: Send + Sync + 'static, Self: Sized,

Optionally add the InsertData layer with the given RefOperator constructor. Read more
source§

fn insert<R, Env, Data, F>(self, f: F) -> Stack<Self, InsertWithData<F>>where F: Fn() -> R, R: for<'a> RefOperator<'a, In, Output = (Env, Option<Data>)>, Env: Send + Sync + 'static, Data: Send + Sync + 'static, Self: Sized,

Add a InsertWithData layer with the given RefOperator constructor. (i.e. a function that returns a RefOperator). Read more
source§

fn insert_if<R, Env, Data, F>( self, enable: bool, f: F ) -> Stack<Self, OptionalLayer<InsertWithData<F>>>where F: Fn() -> R, R: for<'a> RefOperator<'a, In, Output = (Env, Option<Data>)>, Env: Send + Sync + 'static, Data: Send + Sync + 'static, Self: Sized,

Optionally add the InsertWithData layer with the given RefOperator constructor. Read more
source§

fn inspect<F>(self, f: F) -> Stack<Self, Inspect<F>>where F: Fn(&In, &Context) + Clone, Self: Sized,

Add an inspect layer with the given closure.
source§

fn provide<D>(self, data: D) -> Stack<Self, AddData<D>>where D: Clone + Send + Sync + 'static, Self: Sized,

Provide data to the context.
source§

fn provide_if<D>( self, data: Option<D> ) -> Stack<Self, OptionalLayer<AddData<D>>>where D: Clone + Send + Sync + 'static, Self: Sized,

Optionally provide data to the context. Read more
source§

fn provide_with<D>( self, provider: impl Fn() -> Option<D> + Send + Sync + 'static ) -> Stack<Self, AddData<D>>where D: Send + Sync + 'static, Self: Sized,

Provide data to the context with the given data provider.
source§

fn provide_with_if<D>( self, enable: bool, provider: impl Fn() -> Option<D> + Send + Sync + 'static ) -> Stack<Self, OptionalLayer<AddData<D>>>where D: Send + Sync + 'static, Self: Sized,

Optionally provide data to the context with the given data provider. Read more
source§

fn from_context<D>(self) -> Stack<Self, AddData<D>>where D: Send + Sync + 'static, Self: Sized,

👎Deprecated: use data_from_context instead
Declare that the data of type D is in the context.
source§

fn data_from_context<D>(self) -> Stack<Self, AddData<D>>where D: Send + Sync + 'static, Self: Sized,

Declare that the data of type D is in the data context.
source§

fn then_with<Out, F, Builder>( self, builder: Builder ) -> Stack<Self, Then<Builder>>where Builder: Fn() -> F, F: FnMut(Self::Out, &Context) -> Out + Clone, Self: Sized,

Add a closure that will be called after the operator is evaluated.
source§

fn with_if<L>(self, layer: Option<L>) -> Stack<Self, OptionalLayer<L>>where L: Layer<In, Self::Operator>, L::Operator: ContextOperator<In, Out = Self::Out>, Self: Sized,

Optionally add a layer.
§

impl<T> Pointable for T

§

const ALIGN: usize = _

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
source§

impl<T> ToOwned for Twhere T: Clone,

§

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 Twhere U: Into<T>,

§

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 Twhere U: TryFrom<T>,

§

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.