pub struct MapErr<C, E, F> { /* private fields */ }
Expand description
Combinator for modifying encoding/decoding errors.
This is created by calling {DecodeExt, EncodeExt}::map_err
method.
Implementations§
Trait Implementations§
Source§impl<D, E, F> Decode for MapErr<D, E, F>
impl<D, E, F> Decode for MapErr<D, E, F>
Source§fn decode(&mut self, buf: &[u8], eos: Eos) -> Result<usize>
fn decode(&mut self, buf: &[u8], eos: Eos) -> Result<usize>
Consumes the given buffer (a part of a byte sequence), and proceeds the decoding process. Read more
Source§fn finish_decoding(&mut self) -> Result<Self::Item>
fn finish_decoding(&mut self) -> Result<Self::Item>
Finishes the current decoding process and returns the decoded item. Read more
Source§fn requiring_bytes(&self) -> ByteCount
fn requiring_bytes(&self) -> ByteCount
Returns the lower bound of the number of bytes needed to decode the next item. Read more
Source§impl<C, E, F> Encode for MapErr<C, E, F>
impl<C, E, F> Encode for MapErr<C, E, F>
Source§fn encode(&mut self, buf: &mut [u8], eos: Eos) -> Result<usize>
fn encode(&mut self, buf: &mut [u8], eos: Eos) -> Result<usize>
Encodes the items in the encoder and writes the encoded bytes to the given buffer. Read more
Source§fn start_encoding(&mut self, item: Self::Item) -> Result<()>
fn start_encoding(&mut self, item: Self::Item) -> Result<()>
Tries to start encoding the given item. Read more
Source§fn requiring_bytes(&self) -> ByteCount
fn requiring_bytes(&self) -> ByteCount
Returns the number of bytes required to encode all the items in the encoder. Read more
Source§impl<C, E, F> SizedEncode for MapErr<C, E, F>
impl<C, E, F> SizedEncode for MapErr<C, E, F>
Source§fn exact_requiring_bytes(&self) -> u64
fn exact_requiring_bytes(&self) -> u64
Returns the exact number of bytes required to encode all the items remaining in the encoder.
Auto Trait Implementations§
impl<C, E, F> Freeze for MapErr<C, E, F>
impl<C, E, F> RefUnwindSafe for MapErr<C, E, F>
impl<C, E, F> Send for MapErr<C, E, F>
impl<C, E, F> Sync for MapErr<C, E, F>
impl<C, E, F> Unpin for MapErr<C, E, F>
impl<C, E, F> UnwindSafe for MapErr<C, E, F>
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
Source§impl<T> DecodeExt for Twhere
T: Decode,
impl<T> DecodeExt for Twhere
T: Decode,
Source§fn map<T, F>(self, f: F) -> Map<Self, T, F>
fn map<T, F>(self, f: F) -> Map<Self, T, F>
Creates a decoder that converts decoded values by calling the given function. Read more
Source§fn try_map<T, E, F>(self, f: F) -> TryMap<Self, T, E, F>
fn try_map<T, E, F>(self, f: F) -> TryMap<Self, T, E, F>
Creates a decoder that tries to convert decoded values by calling the given function. Read more
Source§fn map_err<E, F>(self, f: F) -> MapErr<Self, E, F>
fn map_err<E, F>(self, f: F) -> MapErr<Self, E, F>
Creates a decoder for modifying decoding errors produced by
self
. Read moreSource§fn and_then<D, F>(self, f: F) -> AndThen<Self, D, F>
fn and_then<D, F>(self, f: F) -> AndThen<Self, D, F>
Creates a decoder that enables conditional decoding. Read more
Source§fn collect<T>(self) -> Collect<Self, T>
fn collect<T>(self) -> Collect<Self, T>
Creates a decoder for collecting decoded items. Read more
Source§fn length(self, expected_bytes: u64) -> Length<Self>
fn length(self, expected_bytes: u64) -> Length<Self>
Creates a decoder that consumes the specified number of bytes exactly. Read more
Source§fn omit(self, do_omit: bool) -> Omittable<Self>
fn omit(self, do_omit: bool) -> Omittable<Self>
Creates a decoder that will omit decoding items if
do_omit = true
is specified. Read moreSource§fn max_bytes(self, bytes: u64) -> MaxBytes<Self>
fn max_bytes(self, bytes: u64) -> MaxBytes<Self>
Creates a decoder that will fail if the number of consumed bytes exceeds
bytes
. Read moreSource§fn chain<T: Decode>(self, other: T) -> TupleDecoder<(Self, T)>
fn chain<T: Decode>(self, other: T) -> TupleDecoder<(Self, T)>
Takes two decoders and creates a new decoder that decodes both items in sequence. Read more
Source§fn slice(self) -> Slice<Self>
fn slice(self) -> Slice<Self>
Creates a decoder that makes it possible to slice the input byte sequence in arbitrary units. Read more
Source§fn peekable(self) -> Peekable<Self>
fn peekable(self) -> Peekable<Self>
Creates a decoder that enables to peek decoded items before calling
finish_decoding
method. Read moreSource§impl<T> EncodeExt for Twhere
T: Encode,
impl<T> EncodeExt for Twhere
T: Encode,
Source§fn with_item(item: Self::Item) -> Result<Self>where
Self: Default,
fn with_item(item: Self::Item) -> Result<Self>where
Self: Default,
Creates a new encoder instance that has the given initial item. Read more
Source§fn map_err<E, F>(self, f: F) -> MapErr<Self, E, F>
fn map_err<E, F>(self, f: F) -> MapErr<Self, E, F>
Creates an encoder for modifying encoding errors produced by
self
. Read moreSource§fn map_from<T, F>(self, f: F) -> MapFrom<Self, T, F>
fn map_from<T, F>(self, f: F) -> MapFrom<Self, T, F>
Creates an encoder that converts items into ones that
suited to the
self
encoder by calling the given function. Read moreSource§fn try_map_from<T, E, F>(self, f: F) -> TryMapFrom<Self, T, E, F>
fn try_map_from<T, E, F>(self, f: F) -> TryMapFrom<Self, T, E, F>
Creates an encoder that tries to convert items into ones that
suited to the
self
encoder by calling the given function. Read moreSource§fn optional(self) -> Optional<Self>
fn optional(self) -> Optional<Self>
Creates an encoder that represents an optional encoder. Read more
Source§fn max_bytes(self, n: u64) -> MaxBytes<Self>
fn max_bytes(self, n: u64) -> MaxBytes<Self>
Creates an encoder that will fail if the number of encoded bytes of an item exceeds
n
. Read moreSource§fn length(self, n: u64) -> Length<Self>
fn length(self, n: u64) -> Length<Self>
Creates an encoder that required to encode each item exactly at the specified number of bytes. Read more
Source§fn chain<T: Encode>(self, other: T) -> TupleEncoder<(Self, T)>
fn chain<T: Encode>(self, other: T) -> TupleEncoder<(Self, T)>
Takes two encoders and creates a new encoder that encodes both items in sequence. Read more
Source§fn repeat<I>(self) -> Repeat<Self, I>
fn repeat<I>(self) -> Repeat<Self, I>
Creates an encoder that repeats encoding of
Self::Item
. Read moreSource§fn pre_encode(self) -> PreEncode<Self>
fn pre_encode(self) -> PreEncode<Self>
Creates an encoder that pre-encodes items when
start_encoding
method is called. Read moreSource§fn slice(self) -> Slice<Self>
fn slice(self) -> Slice<Self>
Creates an encoder that makes it possible to slice the encoded byte sequence in arbitrary units. Read more
Source§impl<T> IoDecodeExt for Twhere
T: Decode,
impl<T> IoDecodeExt for Twhere
T: Decode,
Source§impl<T> IoEncodeExt for Twhere
T: Encode,
impl<T> IoEncodeExt for Twhere
T: Encode,
Source§fn encode_to_write_buf<B>(&mut self, buf: &mut WriteBuf<B>) -> Result<()>
fn encode_to_write_buf<B>(&mut self, buf: &mut WriteBuf<B>) -> Result<()>
Encodes the items remaining in the encoder and
writes the encoded bytes to the given write buffer.
Source§fn encode_to_write_buf_async<B>(
&mut self,
buf: &mut WriteBuf<B>,
cx: &mut Context<'_>,
) -> Result<()>
fn encode_to_write_buf_async<B>( &mut self, buf: &mut WriteBuf<B>, cx: &mut Context<'_>, ) -> Result<()>
Encodes the items remaining in the encoder and
writes the encoded bytes to the given write buffer.
If the write buffer is full and the writing cannot be performed,
the given WriteBuf will memorize cx’s
Waker
.
This Waker
’s wake
will later be called when the WriteBuf
regains its free space.