Skip to main content

Sample

Trait Sample 

Source
pub trait Sample:
    Copy
    + Clone
    + Default
    + Into<i32>
    + Debug
    + Send
    + Sync
    + 'static {
    const MAX_VAL_DEFAULT: i32;
    const BYTES: usize;

    // Required methods
    fn from_i32_clamped(val: i32, max_val: i32) -> Self;
    fn read_le(data: &[u8], offset: usize) -> Self;
    fn write_le(data: &mut [u8], offset: usize, val: Self);
}
Expand description

Trait abstracting a pixel sample type for JPEG-LS encoding/decoding.

Required Associated Constants§

Source

const MAX_VAL_DEFAULT: i32

The maximum sample value (e.g. 255 for 8-bit, 65535 for 16-bit).

Source

const BYTES: usize

Number of bytes per sample.

Required Methods§

Source

fn from_i32_clamped(val: i32, max_val: i32) -> Self

Convert from an i32, clamping to [0, max_val].

Source

fn read_le(data: &[u8], offset: usize) -> Self

Read a sample from a byte slice in native (little-endian) order.

Source

fn write_le(data: &mut [u8], offset: usize, val: Self)

Write a sample to a byte slice in native (little-endian) order.

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 Sample for u8

Source§

const MAX_VAL_DEFAULT: i32 = 255

Source§

const BYTES: usize = 1

Source§

fn from_i32_clamped(val: i32, max_val: i32) -> Self

Source§

fn read_le(data: &[u8], offset: usize) -> Self

Source§

fn write_le(data: &mut [u8], offset: usize, val: Self)

Source§

impl Sample for u16

Source§

const MAX_VAL_DEFAULT: i32 = 65535

Source§

const BYTES: usize = 2

Source§

fn from_i32_clamped(val: i32, max_val: i32) -> Self

Source§

fn read_le(data: &[u8], offset: usize) -> Self

Source§

fn write_le(data: &mut [u8], offset: usize, val: Self)

Implementors§