MapErr

Struct MapErr 

Source
pub struct MapErr<P, Fun> { /* private fields */ }
Expand description

A bulk producer wrapper which changes the error (type) of the wrapped producer, by passing errors through a function.

Use the AsRef<P> impl to access the wrapped producer.

Created via [ProducerExt::map_err].


Counterpart: the [consumer::MapErr] type.

Implementations§

Source§

impl<P, Fun> MapErr<P, Fun>

Source

pub fn into_inner(self) -> P

Consumes self and returns the wrapped producer.

Trait Implementations§

Source§

impl<P, Fun> AsRef<P> for MapErr<P, Fun>

Source§

fn as_ref(&self) -> &P

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl<P, Fun, OldErr, NewErr> BulkProducer for MapErr<P, Fun>
where P: BulkProducer<Error = OldErr>, Fun: FnOnce(OldErr) -> NewErr,

Source§

async fn expose_items<F, R>( &mut self, f: F, ) -> Result<Either<R, Self::Final>, Self::Error>
where F: AsyncFnOnce(&[Self::Item]) -> (usize, R),

Exposes a non-empty number of items to a given async function, the function then reports to the producer how many items should now be considered produced. Read more
Source§

impl<P: Debug, Fun: Debug> Debug for MapErr<P, Fun>

Source§

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

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

impl<P, Fun, OldErr, NewErr> Producer for MapErr<P, Fun>
where P: Producer<Error = OldErr>, Fun: FnOnce(OldErr) -> NewErr,

Source§

type Item = <P as Producer>::Item

The sequence produced by this producer starts with arbitrarily many values of this type.
Source§

type Final = <P as Producer>::Final

The sequence produced by this producer ends with up to one value of this type.
Source§

type Error = NewErr

The type of errors the producer can emit instead of doing its job.
Source§

async fn produce( &mut self, ) -> Result<Either<Self::Item, Self::Final>, Self::Error>

Attempts to produce the next item, which is either a regular repeated item or the final value. The method may fail, returning an Err instead. Read more
Source§

async fn slurp(&mut self) -> Result<(), Self::Error>

Attempts to perform any effectful actions that might make future calls to produce and bulk_produce more efficient. Read more

Auto Trait Implementations§

§

impl<P, Fun> Freeze for MapErr<P, Fun>
where P: Freeze, Fun: Freeze,

§

impl<P, Fun> RefUnwindSafe for MapErr<P, Fun>

§

impl<P, Fun> Send for MapErr<P, Fun>
where P: Send, Fun: Send,

§

impl<P, Fun> Sync for MapErr<P, Fun>
where P: Sync, Fun: Sync,

§

impl<P, Fun> Unpin for MapErr<P, Fun>
where P: Unpin, Fun: Unpin,

§

impl<P, Fun> UnwindSafe for MapErr<P, Fun>
where P: UnwindSafe, Fun: UnwindSafe,

Blanket Implementations§

Source§

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

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

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

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<P> BulkProducerExt for P
where P: BulkProducer + ?Sized,

Source§

async fn expose_items_sync<F, R>( &mut self, f: F, ) -> Result<Either<R, Self::Final>, Self::Error>
where F: FnOnce(&[Self::Item]) -> (usize, R),

Behaves exactly like BulkProducer::expose_items, except the function argument is not async. Read more
Source§

async fn bulk_produce( &mut self, buf: &mut [Self::Item], ) -> Result<Either<usize, Self::Final>, Self::Error>
where Self::Item: Clone,

Calls self.expose_items, clones the exposed items into buf, and returns how many items where written there. Alternatively, forwards any final value or error. This method is mostly analogous to std::io::Read::read. Read more
Source§

async fn bulk_overwrite_full_slice( &mut self, buf: &mut [Self::Item], ) -> Result<(), ProduceAtLeastError<Self::Final, Self::Error>>
where Self::Item: Clone,

Tries to completely overwrite a slice with items from a bulk producer. Reports an error if the slice could not be overwritten completely. Read more
Source§

fn to_bulk_buffered<Q>( self, queue: Q, ) -> BulkBuffered<Self, Self::Final, Self::Error, Q>
where Self: Sized,

Turns self into a buffered bulk producer. Read more
Source§

fn to_bulk_scrambled<Q>( self, buffer: Q, ops: Vec<BulkProducerOperation>, ) -> BulkScrambled<Self, Q, Self::Final, Self::Error>
where Self: Sized,

Turns self into a scrambling producer. Read more
Source§

async fn peek<F, R>( &mut self, f: F, ) -> Result<Either<R, Self::Final>, Self::Error>
where F: AsyncFnOnce(&Self::Item) -> R,

Calls the given async function with a reference to the next item that would be produced, but without actually producing it. Read more
Source§

async fn peek_sync<F, R>( &mut self, f: F, ) -> Result<Either<R, Self::Final>, Self::Error>
where F: FnOnce(&Self::Item) -> R,

Behaves exactly like BulkProducerExt::peek, except the function argument is not async. Read more
Source§

async fn produce_decoded<T>( &mut self, ) -> Result<T, DecodeError<Self::Final, Self::Error, <T as Decodable<Self::Item>>::ErrorReason>>
where T: Decodable<Self::Item>,

Decodes items into some Decodable type T. Read more
Source§

async fn produce_decoded_canonic<T>( &mut self, ) -> Result<T, DecodeError<Self::Final, Self::Error, <T as DecodableCanonic<Self::Item>>::ErrorCanonic>>
where T: DecodableCanonic<Self::Item>,

Canonically decodes items into some Decodable type T. Read more
Source§

async fn produce_relative_decoded<T, RelativeTo>( &mut self, rel: &RelativeTo, ) -> Result<T, DecodeError<Self::Final, Self::Error, <T as RelativeDecodable<RelativeTo, Self::Item>>::ErrorReason>>
where T: RelativeDecodable<RelativeTo, Self::Item>,

Source§

async fn produce_relative_decoded_canonic<T, RelativeTo>( &mut self, rel: &RelativeTo, ) -> Result<T, DecodeError<Self::Final, Self::Error, <T as RelativeDecodableCanonic<RelativeTo, Self::Item>>::ErrorCanonic>>
where T: RelativeDecodableCanonic<RelativeTo, Self::Item>,

Source§

async fn decode_u16_be( &mut self, ) -> Result<u16, DecodeError<Self::Final, Self::Error, Infallible>>
where Self: BulkProducer<Item = u8>,

Returns a u16 by internally producing its big-endian encoding from self. Read more
Source§

async fn decode_u32_be( &mut self, ) -> Result<u32, DecodeError<Self::Final, Self::Error, Infallible>>
where Self: BulkProducer<Item = u8>,

Returns a u32 by internally producing its big-endian encoding from self. Read more
Source§

async fn decode_u64_be( &mut self, ) -> Result<u64, DecodeError<Self::Final, Self::Error, Infallible>>
where Self: BulkProducer<Item = u8>,

Returns a u64 by internally producing its big-endian encoding from self. Read more
Source§

async fn decode_u128_be( &mut self, ) -> Result<u128, DecodeError<Self::Final, Self::Error, Infallible>>
where Self: BulkProducer<Item = u8>,

Returns a u128 by internally producing its big-endian encoding from self. Read more
Source§

async fn decode_i16_be( &mut self, ) -> Result<i16, DecodeError<Self::Final, Self::Error, Infallible>>
where Self: BulkProducer<Item = u8>,

Returns a i16 by internally producing its big-endian encoding from self. Read more
Source§

async fn decode_i32_be( &mut self, ) -> Result<i32, DecodeError<Self::Final, Self::Error, Infallible>>
where Self: BulkProducer<Item = u8>,

Returns a i32 by internally producing its big-endian encoding from self. Read more
Source§

async fn decode_i64_be( &mut self, ) -> Result<i64, DecodeError<Self::Final, Self::Error, Infallible>>
where Self: BulkProducer<Item = u8>,

Returns a i64 by internally producing its big-endian encoding from self. Read more
Source§

async fn decode_i128_be( &mut self, ) -> Result<i128, DecodeError<Self::Final, Self::Error, Infallible>>
where Self: BulkProducer<Item = u8>,

Returns a i128 by internally producing its big-endian encoding from self. Read more
Source§

async fn decode_u16_le( &mut self, ) -> Result<u16, DecodeError<Self::Final, Self::Error, Infallible>>
where Self: BulkProducer<Item = u8>,

Returns a u16 by internally producing its little-endian encoding from self. Read more
Source§

async fn decode_u32_le( &mut self, ) -> Result<u32, DecodeError<Self::Final, Self::Error, Infallible>>
where Self: BulkProducer<Item = u8>,

Returns a u32 by internally producing its little-endian encoding from self. Read more
Source§

async fn decode_u64_le( &mut self, ) -> Result<u64, DecodeError<Self::Final, Self::Error, Infallible>>
where Self: BulkProducer<Item = u8>,

Returns a u64 by internally producing its little-endian encoding from self. Read more
Source§

async fn decode_u128_le( &mut self, ) -> Result<u128, DecodeError<Self::Final, Self::Error, Infallible>>
where Self: BulkProducer<Item = u8>,

Returns a u128 by internally producing its little-endian encoding from self. Read more
Source§

async fn decode_i16_le( &mut self, ) -> Result<i16, DecodeError<Self::Final, Self::Error, Infallible>>
where Self: BulkProducer<Item = u8>,

Returns a i16 by internally producing its little-endian encoding from self. Read more
Source§

async fn decode_i32_le( &mut self, ) -> Result<i32, DecodeError<Self::Final, Self::Error, Infallible>>
where Self: BulkProducer<Item = u8>,

Returns a i32 by internally producing its little-endian encoding from self. Read more
Source§

async fn decode_i64_le( &mut self, ) -> Result<i64, DecodeError<Self::Final, Self::Error, Infallible>>
where Self: BulkProducer<Item = u8>,

Returns a i64 by internally producing its little-endian encoding from self. Read more
Source§

async fn decode_i128_le( &mut self, ) -> Result<i128, DecodeError<Self::Final, Self::Error, Infallible>>
where Self: BulkProducer<Item = u8>,

Returns a i128 by internally producing its little-endian encoding from self. 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 T
where 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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<P> IntoProducer for P
where P: Producer,

Source§

type Item = <P as Producer>::Item

The type of repeated items being produced.
Source§

type Final = <P as Producer>::Final

The type of the final value being produced.
Source§

type Error = <P as Producer>::Error

The type of errors the producer may emit.
Source§

type IntoProducer = P

The producer into which values of this type can be converted. Read more
Source§

fn into_producer(self) -> P

Creates a producer from a value. Read more
Source§

impl<P> ProducerExt for P
where P: Producer + ?Sized,

Source§

async fn produce_item( &mut self, ) -> Result<Self::Item, ProduceAtLeastError<Self::Final, Self::Error>>

Tries to produce a regular item, and reports an error if the final value was produced instead. Read more
Source§

async fn produce_final( &mut self, ) -> Result<Self::Final, ExpectedFinalError<Self::Item, Self::Error>>

Tries to produce a final value, and reports an error if a normal item was produced instead. Read more
Source§

async fn overwrite_full_slice( &mut self, buf: &mut [Self::Item], ) -> Result<(), ProduceAtLeastError<Self::Final, Self::Error>>

Tries to completely overwrite a slice with items from a producer. Reports an error if the slice could not be overwritten completely. Read more
Source§

fn to_buffered<Q>(self, queue: Q) -> Buffered<Self, Self::Final, Self::Error, Q>
where Self: Sized,

Turns self into a buffered bulk producer. Read more
Source§

fn to_scrambled<Q>( self, buffer: Q, ops: Vec<ProducerOperation>, ) -> Scrambled<Self, Q, Self::Final, Self::Error>
where Self: Sized,

Turns self into a scrambling producer. Read more
Source§

async fn equals<P>(&mut self, other: &mut P) -> bool
where P: Producer<Item = Self::Item, Final = Self::Final, Error = Self::Error>, Self::Item: PartialEq, Self::Final: PartialEq, Self::Error: PartialEq,

Returns whether this producer and another producer emit equal sequences of items. Read more
Source§

async fn equals_dbg<P>(&mut self, other: &mut P) -> bool
where P: Producer<Item = Self::Item, Final = Self::Final, Error = Self::Error>, Self::Item: PartialEq + Debug, Self::Final: PartialEq + Debug, Self::Error: PartialEq + Debug,

Exactly the same as ProducerExt::equals but also logs the return values of all produce calls to the terminal. Requires the dev feature.
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

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

Source§

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.