pub trait ReadScalar: FixedSize {
    // Required method
    fn read(bytes: &[u8]) -> Option<Self>;
}
Expand description

A trait for types that can be read from raw bytes.

This is a generalization that gives us a failable read method for all our Scalar types, as well as their BigEndian representations.

You should not need to implement this trait; it is provided automatically when you implement Scalar.

Required Methods§

source

fn read(bytes: &[u8]) -> Option<Self>

Interpret the provided bytes as Self, if they are the right length.

This should use all the provided bytes; bounds checking is performed upstream.

Implementations on Foreign Types§

source§

impl<const N: usize> ReadScalar for [u8; N]

source§

fn read(bytes: &[u8]) -> Option<Self>

Implementors§

source§

impl<T> ReadScalar for BigEndian<T>where T: Scalar + FixedSize, <T as Scalar>::Raw: ReadScalar,

source§

impl<T> ReadScalar for Twhere T: Scalar + FixedSize, <T as Scalar>::Raw: ReadScalar,