Skip to main content

DecodeRangeExt

Trait DecodeRangeExt 

Source
pub trait DecodeRangeExt<X: IsUnit>: Decode<Cfg = (RangeCfg<usize>, X)> {
    // Provided method
    fn decode_range(
        buf: 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 IsUnit, ensuring the buffer is consumed.

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

Provided Methods§

Source

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

Decodes 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: Decode<Cfg = (RangeCfg<usize>, X)>> DecodeRangeExt<X> for U