pub struct SampleEncoding { /* private fields */ }Expand description
Checked interpretation of one integer code in a stored sample.
Extract a code with (sample >> bit_shift) & ((1 << code_bits) - 1) using
sufficiently wide arithmetic. Bits outside that payload are padding: ignored
on read and written as zero on output.
Implementations§
Source§impl SampleEncoding
impl SampleEncoding
Sourcepub const fn new(
storage: SampleType,
code_bits: u8,
bit_shift: u8,
) -> Result<SampleEncoding, SampleEncodingError>
pub const fn new( storage: SampleType, code_bits: u8, bit_shift: u8, ) -> Result<SampleEncoding, SampleEncodingError>
Describe an integer component without examining or changing samples.
storage must be an integer SampleType. code_bits must be in
1..=storage.bits(), and code_bits + bit_shift <= storage.bits().
Sourcepub const fn storage(self) -> SampleType
pub const fn storage(self) -> SampleType
Integer storage type; this does not determine the code depth.
Sourcepub const fn code_bits(self) -> u8
pub const fn code_bits(self) -> u8
Number of significant code bits in the sample representation.
Sourcepub const fn bit_shift(self) -> u8
pub const fn bit_shift(self) -> u8
Number of low padding bits below the code in its stored sample.
Sourcepub const fn to_bit_packing(self) -> Option<BitPacking>
pub const fn to_bit_packing(self) -> Option<BitPacking>
Convert to crate::BitPacking when storage is unsigned (U8, U16, U32).
Trait Implementations§
Source§impl Clone for SampleEncoding
impl Clone for SampleEncoding
Source§fn clone(&self) -> SampleEncoding
fn clone(&self) -> SampleEncoding
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreimpl Copy for SampleEncoding
Source§impl Debug for SampleEncoding
impl Debug for SampleEncoding
impl Eq for SampleEncoding
Source§impl Hash for SampleEncoding
impl Hash for SampleEncoding
Source§impl PartialEq for SampleEncoding
impl PartialEq for SampleEncoding
impl StructuralPartialEq for SampleEncoding
Auto Trait Implementations§
impl Freeze for SampleEncoding
impl RefUnwindSafe for SampleEncoding
impl Send for SampleEncoding
impl Sync for SampleEncoding
impl Unpin for SampleEncoding
impl UnsafeUnpin for SampleEncoding
impl UnwindSafe for SampleEncoding
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more