Skip to main content

ReadFixed

Trait ReadFixed 

Source
pub trait ReadFixed: Read {
    // Provided method
    fn read_fixed<T: FixedReadable>(&mut self) -> Result<T> { ... }
}
Expand description

Extension trait for Read that adds a read_fixed method for types implementing FixedReadable.

Importing this trait instead of (or alongside) ReadValue signals at the call site that the type being read has a statically-known, fixed byte size with no length prefix.

Provided Methods§

Source

fn read_fixed<T: FixedReadable>(&mut self) -> Result<T>

Reads a FixedReadable type from this reader.

Unlike ReadValue::read_value, this method is only callable for fixed-size types — it will not compile for collection types like Vec or String.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§

Source§

impl<T: Read + ?Sized> ReadFixed for T