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(); let (_, item) = decoder.decode(b"foo", Eos::new(true)).unwrap(); assert_eq!(item, Some("foo".to_owned()));
Methods
impl Utf8Decoder<RemainingBytesDecoder>
[src]
pub fn new() -> Self
[src]
Makes a new Utf8Decoder
that uses RemainingBytesDecoder
as the internal bytes decoder.
impl<D> Utf8Decoder<D> where
D: Decode<Item = Vec<u8>>,
[src]
D: Decode<Item = Vec<u8>>,
pub fn with_bytes_decoder(bytes_decoder: D) -> Self
[src]
Makes a new Utf8Decoder
with the given bytes decoder.
Trait Implementations
impl<D: Debug> Debug for Utf8Decoder<D>
[src]
fn fmt(&self, __arg_0: &mut Formatter) -> Result
[src]
Formats the value using the given formatter. Read more
impl<D: Default> Default for Utf8Decoder<D>
[src]
fn default() -> Utf8Decoder<D>
[src]
Returns the "default value" for a type. Read more
impl<D> Decode for Utf8Decoder<D> where
D: Decode<Item = Vec<u8>>,
[src]
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, Option<Self::Item>)>
[src]
&mut self,
buf: &[u8],
eos: Eos
) -> Result<(usize, Option<Self::Item>)>
Consumes the given buffer (a part of a byte sequence), and decodes an item from it. Read more
fn has_terminated(&self) -> bool
[src]
Returns true
if the decoder cannot decode items anymore, otherwise false
. Read more
fn requiring_bytes(&self) -> ByteCount
[src]
Returns the lower bound of the number of bytes needed to decode the next item. Read more
Auto Trait Implementations
impl<D> Send for Utf8Decoder<D> where
D: Send,
D: Send,
impl<D> Sync for Utf8Decoder<D> where
D: Sync,
D: Sync,