Struct bytecodec::bytes::Utf8Decoder [−][src]
pub struct Utf8Decoder<D = RemainingBytesDecoder>(_);
Utf8Decoder
decodes Rust strings from a input byte sequence.
Examples
use bytecodec::{Decode, Eos}; use bytecodec::bytes::Utf8Decoder; let mut decoder = Utf8Decoder::new(); decoder.decode(b"foo", Eos::new(true)).unwrap(); assert_eq!(decoder.finish_decoding().unwrap(), "foo");
Methods
impl Utf8Decoder<RemainingBytesDecoder>
[src]
impl Utf8Decoder<RemainingBytesDecoder>
pub fn new() -> Self
[src]
pub fn new() -> Self
Makes a new Utf8Decoder
that uses RemainingBytesDecoder
as the internal bytes decoder.
impl<D> Utf8Decoder<D> where
D: Decode<Item = Vec<u8>>,
[src]
impl<D> Utf8Decoder<D> where
D: Decode<Item = Vec<u8>>,
pub fn with_bytes_decoder(bytes_decoder: D) -> Self
[src]
pub fn with_bytes_decoder(bytes_decoder: D) -> Self
Makes a new Utf8Decoder
with the given bytes decoder.
ⓘImportant traits for &'a mut Rpub fn inner_ref(&self) -> &D
[src]
pub fn inner_ref(&self) -> &D
Returns a reference to the inner bytes decoder.
ⓘImportant traits for &'a mut Rpub fn inner_mut(&mut self) -> &mut D
[src]
pub fn inner_mut(&mut self) -> &mut D
Returns a mutable reference to the inner bytes decoder.
pub fn into_inner(self) -> D
[src]
pub fn into_inner(self) -> D
Takes ownership of this instance and returns the inner bytes decoder.
Trait Implementations
impl<D: Debug> Debug for Utf8Decoder<D>
[src]
impl<D: Debug> Debug for Utf8Decoder<D>
fn fmt(&self, f: &mut Formatter) -> Result
[src]
fn fmt(&self, f: &mut Formatter) -> Result
Formats the value using the given formatter. Read more
impl<D: Default> Default for Utf8Decoder<D>
[src]
impl<D: Default> Default for Utf8Decoder<D>
fn default() -> Utf8Decoder<D>
[src]
fn default() -> Utf8Decoder<D>
Returns the "default value" for a type. Read more
impl<D> Decode for Utf8Decoder<D> where
D: Decode<Item = Vec<u8>>,
[src]
impl<D> Decode for Utf8Decoder<D> where
D: Decode<Item = Vec<u8>>,
type Item = String
The type of items to be decoded.
fn decode(&mut self, buf: &[u8], eos: Eos) -> Result<usize>
[src]
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
fn finish_decoding(&mut self) -> Result<Self::Item>
[src]
fn finish_decoding(&mut self) -> Result<Self::Item>
Finishes the current decoding process and returns the decoded item. Read more
fn requiring_bytes(&self) -> ByteCount
[src]
fn requiring_bytes(&self) -> ByteCount
Returns the lower bound of the number of bytes needed to decode the next item. Read more
fn is_idle(&self) -> bool
[src]
fn is_idle(&self) -> bool
Returns true
if there are no items to be decoded by the decoder at the next invocation of decode
method, otherwise false
. Read more
Auto Trait Implementations
impl<D> Send for Utf8Decoder<D> where
D: Send,
impl<D> Send for Utf8Decoder<D> where
D: Send,
impl<D> Sync for Utf8Decoder<D> where
D: Sync,
impl<D> Sync for Utf8Decoder<D> where
D: Sync,