Skip to main content

Consume

Trait Consume 

Source
pub trait Consume<T> {
    // Required methods
    fn consume(self) -> Result<T>;
    fn consume_partial(self) -> Option<T>;
}
Expand description

Convenience trait for decoding a value from a byte iterator.

Required Methods§

Source

fn consume(self) -> Result<T>

Consumes the complete iterator to decode a value of T.

§Errors

Returns an Error if the stream terminates prematurely or contains excess bytes after the decoded value.

Source

fn consume_partial(self) -> Option<T>

Decodes one value from the iterator and allows trailing bytes.

Returns None when the iterator does not contain enough bytes for a complete value.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§

Source§

impl<T, I> Consume<T> for I
where T: FromLeStream, I: Iterator<Item = u8>,