Struct audio_time::SampleType
source · pub struct SampleType { /* private fields */ }
Expand description
A type used to encode a single sample, created from a type that implements audio_core::Sample.
This struct “erases” the type it was created with, to allow it to be used as
a const generic. On creation, it encodes the size of the sample type, which
can be retrieved later using byte_depth
.
The struct also encodes the type’s unique type_id
, so that two
SampleType
s created from different types with the same size are not
equal, e.g.:
assert_eq!(SampleType::new::<i16>(), SampleType::new::<i16>());
assert_ne!(SampleType::new::<i16>(), SampleType::new::<u16>());
Implementations§
source§impl SampleType
impl SampleType
pub const fn new<Sample: Sample + 'static>() -> Self
sourcepub const fn byte_depth(&self) -> NonZeroU8
pub const fn byte_depth(&self) -> NonZeroU8
The number of bytes used to represent this sample type.
Trait Implementations§
source§impl Clone for SampleType
impl Clone for SampleType
source§fn clone(&self) -> SampleType
fn clone(&self) -> SampleType
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moresource§impl Debug for SampleType
impl Debug for SampleType
source§impl Hash for SampleType
impl Hash for SampleType
source§impl Ord for SampleType
impl Ord for SampleType
source§fn cmp(&self, other: &SampleType) -> Ordering
fn cmp(&self, other: &SampleType) -> Ordering
1.21.0 · source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere Self: Sized,
Compares and returns the maximum of two values. Read more
source§impl PartialEq<SampleType> for SampleType
impl PartialEq<SampleType> for SampleType
source§fn eq(&self, other: &SampleType) -> bool
fn eq(&self, other: &SampleType) -> bool
This method tests for
self
and other
values to be equal, and is used
by ==
.source§impl PartialOrd<SampleType> for SampleType
impl PartialOrd<SampleType> for SampleType
source§fn partial_cmp(&self, other: &SampleType) -> Option<Ordering>
fn partial_cmp(&self, other: &SampleType) -> Option<Ordering>
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for
self
and other
) and is used by the <=
operator. Read more