Skip to main content

ArrayElement

Trait ArrayElement 

Source
pub trait ArrayElement: Copy + 'static {
    // Required methods
    fn dtype_id() -> u8;
    fn element_size() -> usize;
    fn from_le_bytes_slice(bytes: &[u8], n: usize) -> Vec<Self>;
    fn to_le_bytes_vec(slice: &[Self]) -> Vec<u8> ;
}
Expand description

Element type supported by the .scirs2 array payload.

Each concrete type carries a stable 1-byte dtype_id embedded in the file, enabling typed deserialization and cross-language interoperability.

§Dtype IDs

IDType
1f32
2f64
3i32
4i64
5u32
6u64

Required Methods§

Source

fn dtype_id() -> u8

Stable 1-byte dtype identifier embedded in the binary format.

Source

fn element_size() -> usize

Size in bytes of one element.

Source

fn from_le_bytes_slice(bytes: &[u8], n: usize) -> Vec<Self>

Deserialize n elements from a little-endian byte slice.

Source

fn to_le_bytes_vec(slice: &[Self]) -> Vec<u8>

Serialize a slice of elements to little-endian bytes.

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 ArrayElement for f32

Source§

fn dtype_id() -> u8

Source§

fn element_size() -> usize

Source§

fn from_le_bytes_slice(bytes: &[u8], n: usize) -> Vec<Self>

Source§

fn to_le_bytes_vec(slice: &[Self]) -> Vec<u8>

Source§

impl ArrayElement for f64

Source§

fn dtype_id() -> u8

Source§

fn element_size() -> usize

Source§

fn from_le_bytes_slice(bytes: &[u8], n: usize) -> Vec<Self>

Source§

fn to_le_bytes_vec(slice: &[Self]) -> Vec<u8>

Source§

impl ArrayElement for i32

Source§

fn dtype_id() -> u8

Source§

fn element_size() -> usize

Source§

fn from_le_bytes_slice(bytes: &[u8], n: usize) -> Vec<Self>

Source§

fn to_le_bytes_vec(slice: &[Self]) -> Vec<u8>

Source§

impl ArrayElement for i64

Source§

fn dtype_id() -> u8

Source§

fn element_size() -> usize

Source§

fn from_le_bytes_slice(bytes: &[u8], n: usize) -> Vec<Self>

Source§

fn to_le_bytes_vec(slice: &[Self]) -> Vec<u8>

Source§

impl ArrayElement for u32

Source§

fn dtype_id() -> u8

Source§

fn element_size() -> usize

Source§

fn from_le_bytes_slice(bytes: &[u8], n: usize) -> Vec<Self>

Source§

fn to_le_bytes_vec(slice: &[Self]) -> Vec<u8>

Source§

impl ArrayElement for u64

Source§

fn dtype_id() -> u8

Source§

fn element_size() -> usize

Source§

fn from_le_bytes_slice(bytes: &[u8], n: usize) -> Vec<Self>

Source§

fn to_le_bytes_vec(slice: &[Self]) -> Vec<u8>

Implementors§