Struct bytecodec::combinator::Slice
[−]
[src]
pub struct Slice<T> { /* fields omitted */ }Combinator for slicing an input/output byte sequence by the specified number of bytes.
This is created by calling {DecodeExt, EncodeExt}::slice.
Methods
impl<T> Slice<T>[src]
pub fn consumable_bytes(&self) -> u64[src]
Returns the number of remaining bytes consumable in this slice.
The inner decoder or encoder will be suspended if the consumable bytes reaches to 0.
pub fn set_consumable_bytes(&mut self, n: u64)[src]
Set the number of remaining bytes consumable in this slice.
pub fn is_suspended(&self) -> bool[src]
Returns true if the encoder or decoder cannot consume any more bytes, otherwise false.
To resume its works, it is needed to reset the value of consumable bytes
by calling set_consumable_bytes method.
ⓘImportant traits for &'a mut Wpub fn inner_ref(&self) -> &T[src]
Returns a reference to the inner encoder or decoder.
ⓘImportant traits for &'a mut Wpub fn inner_mut(&mut self) -> &mut T[src]
Returns a mutable reference to the inner encoder or decoder.
pub fn into_inner(self) -> T[src]
Takes ownership of this instance and returns the inner encoder or decoder.
Trait Implementations
impl<T: Debug> Debug for Slice<T>[src]
fn fmt(&self, __arg_0: &mut Formatter) -> Result[src]
Formats the value using the given formatter. Read more
impl<T: Default> Default for Slice<T>[src]
impl<D: Decode> Decode for Slice<D>[src]
type Item = D::Item
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 is_idle(&self) -> bool[src]
Returns true if there is no item being decoded by the decoder, otherwise false.
fn requiring_bytes(&self) -> ByteCount[src]
Returns the lower bound of the number of bytes needed to decode the next item. Read more
impl<E: Encode> Encode for Slice<E>[src]
type Item = E::Item
The type of items to be encoded.
fn encode(&mut self, buf: &mut [u8], eos: Eos) -> Result<usize>[src]
Encodes the items in the encoder and writes the encoded bytes to the given buffer. Read more
fn start_encoding(&mut self, item: Self::Item) -> Result<()>[src]
Tries to start encoding the given item. Read more
fn is_idle(&self) -> bool[src]
Returns true if there are no items to be encoded in the encoder, otherwise false.
fn requiring_bytes(&self) -> ByteCount[src]
Returns the number of bytes required to encode all the items in the encoder. Read more
impl<E: ExactBytesEncode> ExactBytesEncode for Slice<E>[src]
fn exact_requiring_bytes(&self) -> u64[src]
Returns the exact number of bytes required to encode all the items remaining in the encoder.