Skip to main content

Sample

Trait Sample 

Source
pub trait Sample:
    Copy
    + Default
    + Sealed
    + 'static {
    const DATA_TYPE: DataType;
    const IS_INTEGER: bool;

    // Required methods
    fn from_f64(value: f64) -> Self;
    fn to_f64(self) -> f64;
    fn read_le(bytes: &[u8]) -> Result<Self>;
    fn write_le(self, out: &mut Vec<u8>);
    fn into_pixel_data(values: Vec<Self>) -> PixelData;

    // Provided method
    fn read_vec(bytes: &[u8]) -> Result<Vec<Self>> { ... }
}
Expand description

Primitive sample types supported by LERC.

This trait is sealed and implemented for i8, u8, i16, u16, i32, u32, f32, and f64.

Required Associated Constants§

Source

const DATA_TYPE: DataType

Corresponding runtime DataType.

Source

const IS_INTEGER: bool

Whether this sample is an integer type.

Required Methods§

Source

fn from_f64(value: f64) -> Self

Converts an f64 with Rust’s primitive numeric-cast semantics.

Source

fn to_f64(self) -> f64

Promotes the sample to f64.

Source

fn read_le(bytes: &[u8]) -> Result<Self>

Reads one little-endian sample.

Source

fn write_le(self, out: &mut Vec<u8>)

Appends one little-endian sample.

Source

fn into_pixel_data(values: Vec<Self>) -> PixelData

Wraps a homogeneous buffer in PixelData.

Provided Methods§

Source

fn read_vec(bytes: &[u8]) -> Result<Vec<Self>>

Reads an aligned little-endian sample buffer.

Dyn Compatibility§

This trait is not dyn compatible.

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

Implementations on Foreign Types§

Source§

impl Sample for f32

Source§

const DATA_TYPE: DataType = DataType::F32

Source§

const IS_INTEGER: bool = false

Source§

fn from_f64(value: f64) -> Self

Source§

fn to_f64(self) -> f64

Source§

fn read_le(bytes: &[u8]) -> Result<Self>

Source§

fn write_le(self, out: &mut Vec<u8>)

Source§

fn into_pixel_data(values: Vec<Self>) -> PixelData

Source§

impl Sample for f64

Source§

const DATA_TYPE: DataType = DataType::F64

Source§

const IS_INTEGER: bool = false

Source§

fn from_f64(value: f64) -> Self

Source§

fn to_f64(self) -> f64

Source§

fn read_le(bytes: &[u8]) -> Result<Self>

Source§

fn write_le(self, out: &mut Vec<u8>)

Source§

fn into_pixel_data(values: Vec<Self>) -> PixelData

Source§

impl Sample for i8

Source§

const DATA_TYPE: DataType = DataType::I8

Source§

const IS_INTEGER: bool = true

Source§

fn from_f64(value: f64) -> Self

Source§

fn to_f64(self) -> f64

Source§

fn read_le(bytes: &[u8]) -> Result<Self>

Source§

fn write_le(self, out: &mut Vec<u8>)

Source§

fn into_pixel_data(values: Vec<Self>) -> PixelData

Source§

impl Sample for i16

Source§

const DATA_TYPE: DataType = DataType::I16

Source§

const IS_INTEGER: bool = true

Source§

fn from_f64(value: f64) -> Self

Source§

fn to_f64(self) -> f64

Source§

fn read_le(bytes: &[u8]) -> Result<Self>

Source§

fn write_le(self, out: &mut Vec<u8>)

Source§

fn into_pixel_data(values: Vec<Self>) -> PixelData

Source§

impl Sample for i32

Source§

const DATA_TYPE: DataType = DataType::I32

Source§

const IS_INTEGER: bool = true

Source§

fn from_f64(value: f64) -> Self

Source§

fn to_f64(self) -> f64

Source§

fn read_le(bytes: &[u8]) -> Result<Self>

Source§

fn write_le(self, out: &mut Vec<u8>)

Source§

fn into_pixel_data(values: Vec<Self>) -> PixelData

Source§

impl Sample for u8

Source§

const DATA_TYPE: DataType = DataType::U8

Source§

const IS_INTEGER: bool = true

Source§

fn from_f64(value: f64) -> Self

Source§

fn to_f64(self) -> f64

Source§

fn read_le(bytes: &[u8]) -> Result<Self>

Source§

fn write_le(self, out: &mut Vec<u8>)

Source§

fn into_pixel_data(values: Vec<Self>) -> PixelData

Source§

impl Sample for u16

Source§

const DATA_TYPE: DataType = DataType::U16

Source§

const IS_INTEGER: bool = true

Source§

fn from_f64(value: f64) -> Self

Source§

fn to_f64(self) -> f64

Source§

fn read_le(bytes: &[u8]) -> Result<Self>

Source§

fn write_le(self, out: &mut Vec<u8>)

Source§

fn into_pixel_data(values: Vec<Self>) -> PixelData

Source§

impl Sample for u32

Source§

const DATA_TYPE: DataType = DataType::U32

Source§

const IS_INTEGER: bool = true

Source§

fn from_f64(value: f64) -> Self

Source§

fn to_f64(self) -> f64

Source§

fn read_le(bytes: &[u8]) -> Result<Self>

Source§

fn write_le(self, out: &mut Vec<u8>)

Source§

fn into_pixel_data(values: Vec<Self>) -> PixelData

Implementors§