[][src]Trait elrond_codec::Input

pub trait Input {
    fn remaining_len(&mut self) -> usize;
fn read_into(&mut self, into: &mut [u8]) -> Result<(), DecodeError>;
fn read_slice(&mut self, length: usize) -> Result<&[u8], DecodeError>;
fn flush(&mut self) -> Result<&[u8], DecodeError>; fn empty(&mut self) -> bool { ... }
fn read_byte(&mut self) -> Result<u8, DecodeError> { ... } }

Trait that allows reading of data into a slice.

Required methods

fn remaining_len(&mut self) -> usize

Should return the remaining length of the input data. If no information about the input length is available, None should be returned.

The length is used to constrain the preallocation while decoding. Returning a garbage length can open the doors for a denial of service attack to your application. Otherwise, returning None can decrease the performance of your application.

fn read_into(&mut self, into: &mut [u8]) -> Result<(), DecodeError>

Read the exact number of bytes required to fill the given buffer.

fn read_slice(&mut self, length: usize) -> Result<&[u8], DecodeError>

Read the exact number of bytes required to fill the given buffer.

fn flush(&mut self) -> Result<&[u8], DecodeError>

Loading content...

Provided methods

fn empty(&mut self) -> bool

fn read_byte(&mut self) -> Result<u8, DecodeError>

Read a single byte from the input.

Loading content...

Implementors

impl<'a> Input for &'a [u8][src]

Loading content...