pub struct PredicateCodec<T, U, P> { /* private fields */ }
Expand description

Represents a codec that invokes one of two codecs based on the given predicate

Implementations§

source§

impl<T, U, P> PredicateCodec<T, U, P>

source

pub fn new(left: T, right: U, predicate: P) -> Self

Creates a new predicate codec where the left codec is invoked if the predicate returns true and the right codec is invoked if the predicate returns false

source

pub fn as_left(&self) -> &T

Returns reference to left codec

source

pub fn into_left(self) -> T

Consumes the chain and returns the left codec

source

pub fn as_right(&self) -> &U

Returns reference to right codec

source

pub fn into_right(self) -> U

Consumes the chain and returns the right codec

source

pub fn into_left_right(self) -> (T, U)

Consumes the chain and returns the left and right codecs

Trait Implementations§

source§

impl<T, U, P> Clone for PredicateCodec<T, U, P>where T: Clone, U: Clone,

source§

fn clone(&self) -> Self

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<T, U, P> Codec for PredicateCodec<T, U, P>where T: Codec + Clone, U: Codec + Clone, P: Fn(&Frame<'_>) -> bool,

source§

fn encode<'a>(&mut self, frame: Frame<'a>) -> Result<Frame<'a>>

Encodes a frame’s item
source§

fn decode<'a>(&mut self, frame: Frame<'a>) -> Result<Frame<'a>>

Decodes a frame’s item
source§

impl<T: Debug, U: Debug, P: Debug> Debug for PredicateCodec<T, U, P>

source§

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

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

impl<T: Default, U: Default, P: Default> Default for PredicateCodec<T, U, P>

source§

fn default() -> PredicateCodec<T, U, P>

Returns the “default value” for a type. Read more
source§

impl<T: PartialEq, U: PartialEq, P: PartialEq> PartialEq<PredicateCodec<T, U, P>> for PredicateCodec<T, U, P>

source§

fn eq(&self, other: &PredicateCodec<T, U, P>) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl<T: Eq, U: Eq, P: Eq> Eq for PredicateCodec<T, U, P>

source§

impl<T, U, P> StructuralEq for PredicateCodec<T, U, P>

source§

impl<T, U, P> StructuralPartialEq for PredicateCodec<T, U, P>

Auto Trait Implementations§

§

impl<T, U, P> RefUnwindSafe for PredicateCodec<T, U, P>where P: RefUnwindSafe, T: RefUnwindSafe, U: RefUnwindSafe,

§

impl<T, U, P> Send for PredicateCodec<T, U, P>where P: Send + Sync, T: Send, U: Send,

§

impl<T, U, P> Sync for PredicateCodec<T, U, P>where P: Send + Sync, T: Sync, U: Sync,

§

impl<T, U, P> Unpin for PredicateCodec<T, U, P>where T: Unpin, U: Unpin,

§

impl<T, U, P> UnwindSafe for PredicateCodec<T, U, P>where P: RefUnwindSafe, T: UnwindSafe, U: 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> AsAny for Twhere T: 'static,

source§

fn as_any(&self) -> &(dyn Any + 'static)

Converts reference to Any
source§

fn as_mut_any(&mut self) -> &mut (dyn Any + 'static)

Converts mutable reference to Any
source§

fn into_any(self: Box<T, Global>) -> Box<dyn Any + 'static, Global>

Consumes and produces Box<dyn Any>
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<C> CodecExt for Cwhere C: Codec,

source§

fn chain<T>(self, codec: T) -> ChainCodec<C, T>

Chains this codec with another codec
source§

impl<T> DynClone for Twhere T: Clone,

source§

fn __clone_box(&self, _: Private) -> *mut ()

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<T> Same<T> for T

§

type Output = T

Should always be Self
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.
§

impl<V, T> VZip<V> for Twhere V: MultiLane<T>,

§

fn vzip(self) -> V