Skip to main content

SampleFormat

Enum SampleFormat 

Source
#[non_exhaustive]
#[repr(u8)]
pub enum SampleFormat { U8 = 0, S8 = 1, S16 = 2, S24 = 3, S32 = 4, F32 = 5, F64 = 6, U8P = 7, S16P = 8, S32P = 9, F32P = 10, F64P = 11, }
Expand description

Audio sample format.

Variants carry stable explicit discriminants — the integer value of SampleFormat::S16 as u8 is part of the public ABI. Add new variants only at the end with a fresh number; never reorder, renumber, or remove. #[non_exhaustive] lets the enum grow without breaking downstream match statements; pinned discriminants additionally let the format round-trip through any byte-stable serialization (config files, capability blobs, IPC) without losing meaning across crate versions.

Variants (Non-exhaustive)§

This enum is marked as non-exhaustive
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
§

U8 = 0

Unsigned 8-bit, interleaved.

§

S8 = 1

Signed 8-bit, interleaved. Native format of Amiga 8SVX and MOD samples.

§

S16 = 2

Signed 16-bit little-endian, interleaved.

§

S24 = 3

Signed 24-bit packed (3 bytes/sample) little-endian, interleaved.

§

S32 = 4

Signed 32-bit little-endian, interleaved.

§

F32 = 5

32-bit IEEE float, interleaved.

§

F64 = 6

64-bit IEEE float, interleaved.

§

U8P = 7

Planar variants — one plane per channel.

§

S16P = 8

§

S32P = 9

§

F32P = 10

§

F64P = 11

Implementations§

Source§

impl SampleFormat

Source

pub fn is_planar(&self) -> bool

Source

pub fn bytes_per_sample(&self) -> usize

Bytes per sample per channel.

Source

pub fn is_float(&self) -> bool

Source

pub fn plane_count(&self, channels: u16) -> usize

Number of Vec<u8> planes an AudioFrame of this format carries for channels channels: planar formats use one plane per channel, interleaved formats use one plane total.

Trait Implementations§

Source§

impl Clone for SampleFormat

Source§

fn clone(&self) -> SampleFormat

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for SampleFormat

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Hash for SampleFormat

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl PartialEq for SampleFormat

Source§

fn eq(&self, other: &SampleFormat) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Copy for SampleFormat

Source§

impl Eq for SampleFormat

Source§

impl StructuralPartialEq for SampleFormat

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.