pub trait Sample:
Sealed
+ Copy
+ PartialOrd
+ Default
+ Debug {
const DATA_TYPE: DataType;
const BYTES: usize;
// Required methods
fn to_f64(self) -> f64;
fn from_f64(v: f64) -> Self;
fn to_bits_u64(self) -> u64;
fn from_bits_u64(v: u64) -> Self;
fn is_integer() -> bool;
fn into_lerc_data(v: Vec<Self>) -> SampleData;
fn try_ref_lerc_data(data: &SampleData) -> Option<&[Self]>;
fn try_from_lerc_data(data: SampleData) -> Result<Vec<Self>, SampleData>;
fn from_le_slice(s: &[u8]) -> Self;
fn extend_le_bytes(self, buf: &mut Vec<u8>);
fn min_representable() -> f64;
}Expand description
Trait for pixel types that can be encoded/decoded with LERC.
Implemented for i8, u8, i16, u16, i32, u32, f32, and f64.
Required Associated Constants§
Required Methods§
Sourcefn to_bits_u64(self) -> u64
fn to_bits_u64(self) -> u64
Reinterpret this value’s bits as a u64.
Sourcefn from_bits_u64(v: u64) -> Self
fn from_bits_u64(v: u64) -> Self
Reinterpret a u64’s bits as this type.
Sourcefn is_integer() -> bool
fn is_integer() -> bool
Returns true if this is an integer pixel type.
Sourcefn into_lerc_data(v: Vec<Self>) -> SampleData
fn into_lerc_data(v: Vec<Self>) -> SampleData
Wrap a Vec<Self> into the corresponding SampleData variant.
Sourcefn try_ref_lerc_data(data: &SampleData) -> Option<&[Self]>
fn try_ref_lerc_data(data: &SampleData) -> Option<&[Self]>
Try to borrow the pixel slice from a SampleData if the variant matches.
Sourcefn try_from_lerc_data(data: SampleData) -> Result<Vec<Self>, SampleData>
fn try_from_lerc_data(data: SampleData) -> Result<Vec<Self>, SampleData>
Try to unwrap the pixel vector from a SampleData if the variant matches.
Sourcefn from_le_slice(s: &[u8]) -> Self
fn from_le_slice(s: &[u8]) -> Self
Read a value from a little-endian byte slice. The slice must be at least BYTES long.
Sourcefn extend_le_bytes(self, buf: &mut Vec<u8>)
fn extend_le_bytes(self, buf: &mut Vec<u8>)
Write this value as little-endian bytes to a Vec.
Sourcefn min_representable() -> f64
fn min_representable() -> f64
The minimum representable value for this type as f64.
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.