Skip to main content

ReadRangeExt

Trait ReadRangeExt 

Source
pub trait ReadRangeExt<X: IsUnit>: Read<Cfg = (RangeCfg<usize>, X)> {
    // Provided method
    fn read_range(
        buf: &mut impl Buf,
        range: impl RangeBounds<usize>,
    ) -> Result<Self, Error> { ... }
}
Expand description

Extension trait for reading types whose config is (RangeCfg<usize>, X) where X is Default.

Useful for reading collections like Vec<T> where T implements Read with no specific configuration. Import this trait to use the .read_range() method.

Provided Methods§

Source

fn read_range( buf: &mut impl Buf, range: impl RangeBounds<usize>, ) -> Result<Self, Error>

Reads a value using only a range configuration.

The inner configuration type X must be IsUnit and X::default() is used for it.

Dyn Compatibility§

This trait is not dyn compatible.

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

Implementors§

Source§

impl<X: IsUnit, U: Read<Cfg = (RangeCfg<usize>, X)>> ReadRangeExt<X> for U