ScalarBytes

Trait ScalarBytes 

Source
pub trait ScalarBytes: Scalar {
    // Required method
    fn from_le_bytes(bytes: &[u8]) -> Self;
}
Expand description

A byte-aligned Scalar that can be decoded from its little-endian byte representation.

Excludes sub-byte scalars like i4 for which a single element cannot be addressed at a byte boundary. This is what crate::memory_tensor::HostTensor::from_safetensors requires, matching the set of dtypes safetensors itself can carry.

Required Methods§

Source

fn from_le_bytes(bytes: &[u8]) -> Self

Decodes one element from bytes; bytes.len() must equal Self::BITS / 8.

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.

Implementations on Foreign Types§

Source§

impl ScalarBytes for f32

Source§

fn from_le_bytes(bytes: &[u8]) -> Self

Source§

impl ScalarBytes for i8

Source§

fn from_le_bytes(bytes: &[u8]) -> Self

Source§

impl ScalarBytes for i16

Source§

fn from_le_bytes(bytes: &[u8]) -> Self

Source§

impl ScalarBytes for i32

Source§

fn from_le_bytes(bytes: &[u8]) -> Self

Source§

impl ScalarBytes for u8

Source§

fn from_le_bytes(bytes: &[u8]) -> Self

Implementors§