pub trait Decoder<T: Copy + From<u8>> {
// Required method
fn decode(&mut self, buffer: &mut [T]) -> Result<usize>;
// Provided method
fn to_vec(self) -> Result<Vec<T>>
where Self: Sized { ... }
}
Expand description
Represents an object that can decode a stream of data into a buffer of fixed size. A type parameter T
specifies /// the type of the elements in the buffer.
Required Methods§
sourcefn decode(&mut self, buffer: &mut [T]) -> Result<usize>
fn decode(&mut self, buffer: &mut [T]) -> Result<usize>
Decodes next elements into the buffer
Decodes next elements and returns the number of decoded elements, or zero if the end of the stream is reached. There is no guarantee about buffer element past the return value. They might be left unchanged or zeroed out by this method.