pub struct SampleRate(pub NonZeroU32);Expand description
A sample rate in hertz, guaranteed non-zero.
Use one of the HZ_* constants for the rates audiofp supports out of the
box, or SampleRate::new to validate an arbitrary value.
§Example
use audiofp::SampleRate;
assert_eq!(SampleRate::HZ_44100.hz(), 44_100);
assert!(SampleRate::new(0).is_none());Tuple Fields§
§0: NonZeroU32Implementations§
Source§impl SampleRate
impl SampleRate
Sourcepub const HZ_8000: SampleRate
pub const HZ_8000: SampleRate
8 kHz — the rate audiofp’s classical fingerprinters consume.
Sourcepub const HZ_11025: SampleRate
pub const HZ_11025: SampleRate
11.025 kHz.
Sourcepub const HZ_16000: SampleRate
pub const HZ_16000: SampleRate
16 kHz — typical speech rate.
Sourcepub const HZ_22050: SampleRate
pub const HZ_22050: SampleRate
22.05 kHz — common for music workflows.
Sourcepub const HZ_44100: SampleRate
pub const HZ_44100: SampleRate
44.1 kHz — CD-quality audio.
Sourcepub const HZ_48000: SampleRate
pub const HZ_48000: SampleRate
48 kHz — DAT / professional audio.
Sourcepub const fn new(hz: u32) -> Option<SampleRate>
pub const fn new(hz: u32) -> Option<SampleRate>
Build a SampleRate from any non-zero u32.
Returns None if hz == 0.
§Example
use audiofp::SampleRate;
assert_eq!(SampleRate::new(32_000).unwrap().hz(), 32_000);
assert!(SampleRate::new(0).is_none());Trait Implementations§
Source§impl Clone for SampleRate
impl Clone for SampleRate
Source§fn clone(&self) -> SampleRate
fn clone(&self) -> SampleRate
Returns a duplicate 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 SampleRate
impl Debug for SampleRate
Source§impl Hash for SampleRate
impl Hash for SampleRate
Source§impl PartialEq for SampleRate
impl PartialEq for SampleRate
impl Copy for SampleRate
impl Eq for SampleRate
impl StructuralPartialEq for SampleRate
Auto Trait Implementations§
impl Freeze for SampleRate
impl RefUnwindSafe for SampleRate
impl Send for SampleRate
impl Sync for SampleRate
impl Unpin for SampleRate
impl UnsafeUnpin for SampleRate
impl UnwindSafe for SampleRate
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