pub struct AudioFormat {
pub format_type: AudioFormatType,
pub sample_rate: u32,
pub channels: u16,
pub bits_per_sample: Option<u16>,
pub bit_rate: Option<u32>,
pub duration: Option<f64>,
pub metadata: HashMap<String, String>,
}Expand description
Audio format specification with detailed parameters
Fields§
§format_type: AudioFormatTypeFormat type
sample_rate: u32Sample rate in Hz
channels: u16Number of channels
bits_per_sample: Option<u16>Bits per sample (for uncompressed formats)
bit_rate: Option<u32>Bit rate (for compressed formats)
duration: Option<f64>Duration in seconds
metadata: HashMap<String, String>Additional format-specific metadata
Implementations§
Source§impl AudioFormat
impl AudioFormat
Sourcepub fn new(
format_type: AudioFormatType,
sample_rate: u32,
channels: u16,
) -> Self
pub fn new( format_type: AudioFormatType, sample_rate: u32, channels: u16, ) -> Self
Create new audio format
Sourcepub fn with_bits_per_sample(self, bits: u16) -> Self
pub fn with_bits_per_sample(self, bits: u16) -> Self
Set bits per sample
Sourcepub fn with_bit_rate(self, rate: u32) -> Self
pub fn with_bit_rate(self, rate: u32) -> Self
Set bit rate for compressed formats
Sourcepub fn with_duration(self, duration: f64) -> Self
pub fn with_duration(self, duration: f64) -> Self
Set duration
Sourcepub fn with_metadata(self, key: String, value: String) -> Self
pub fn with_metadata(self, key: String, value: String) -> Self
Add metadata
Sourcepub fn estimated_file_size(&self, duration_seconds: f64) -> u64
pub fn estimated_file_size(&self, duration_seconds: f64) -> u64
Calculate estimated file size for audio
Sourcepub fn supports_sample_rate(&self, sample_rate: u32) -> bool
pub fn supports_sample_rate(&self, sample_rate: u32) -> bool
Check if format supports the given sample rate
Trait Implementations§
Source§impl Clone for AudioFormat
impl Clone for AudioFormat
Source§fn clone(&self) -> AudioFormat
fn clone(&self) -> AudioFormat
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 AudioFormat
impl Debug for AudioFormat
Source§impl Default for AudioFormat
impl Default for AudioFormat
Source§impl<'de> Deserialize<'de> for AudioFormat
impl<'de> Deserialize<'de> for AudioFormat
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl PartialEq for AudioFormat
impl PartialEq for AudioFormat
Source§impl Serialize for AudioFormat
impl Serialize for AudioFormat
impl StructuralPartialEq for AudioFormat
Auto Trait Implementations§
impl Freeze for AudioFormat
impl RefUnwindSafe for AudioFormat
impl Send for AudioFormat
impl Sync for AudioFormat
impl Unpin for AudioFormat
impl UnsafeUnpin for AudioFormat
impl UnwindSafe for AudioFormat
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more