Struct Header

Source
pub struct Header {
    pub source: HeaderSource,
    pub version: Option<Version>,
    pub layer: Option<Layer>,
    pub mode: Option<Mode>,
    pub min_channel_count: u8,
    pub max_channel_count: u8,
    pub min_sample_rate_hz: u16,
    pub max_sample_rate_hz: u16,
    pub total_sample_count: u64,
    pub total_duration: Duration,
    pub avg_sample_rate_hz: Option<u16>,
    pub avg_bitrate_bps: Option<u32>,
}
Expand description

Properties of an MPEG audio stream

A virtual MPEG audio header, built from both the XING header and optionally aggregated from all valid MPEG frame headers.

Fields§

§source: HeaderSource

Source of the metadata in this header

§version: Option<Version>

MPEG version

The common MPEG version in all frames or None if either unknown or inconsistent.

§layer: Option<Layer>

MPEG layer

The common MPEG layer in all frames or None if either unknown or inconsistent.

§mode: Option<Mode>

MPEG mode

The common MPEG mode in all frames or None if either unknown or inconsistent.

§min_channel_count: u8

Minimum number of channels

§max_channel_count: u8

Maximum number of channels

§min_sample_rate_hz: u16

Minimum sample rate in Hz

§max_sample_rate_hz: u16

Maximum sample rate in Hz

§total_sample_count: u64

Total number of samples per channel

§total_duration: Duration

Total duration

§avg_sample_rate_hz: Option<u16>

Average sample rate in Hz

§avg_bitrate_bps: Option<u32>

Average bitrate in bits/sec

Implementations§

Source§

impl Header

Source

pub fn read_from_source( source: &mut impl Read, parse_mode: ParseMode, ) -> PositionalResult<Self>

Read from a source that implements Read

§Errors

Returns a PositionalError on any kind of failure.

§Examples
use std::{path::Path, fs::File, io::BufReader};
use mpeg_audio_header::{Header, ParseMode};

let path = Path::new("test/source.mp3");
let file = File::open(path).unwrap();
let mut source = BufReader::new(file);
let header = Header::read_from_source(&mut source, ParseMode::IgnoreVbrHeaders).unwrap();
println!("MPEG audio header: {:?}", header);
Source

pub fn read_from_file( file: &File, parse_mode: ParseMode, ) -> PositionalResult<Self>

Read from a file

§Errors

Returns a PositionalError on any kind of failure.

§Examples
use std::{path::Path, fs::File};
use mpeg_audio_header::{Header, ParseMode};

let path = Path::new("test/source.mp3");
let file = File::open(path).unwrap();
let header = Header::read_from_file(&file, ParseMode::PreferVbrHeaders).unwrap();
println!("MPEG audio header: {:?}", header);
Source

pub fn read_from_path( path: impl AsRef<Path>, parse_mode: ParseMode, ) -> PositionalResult<Self>

Read from a file path

§Errors

Returns a PositionalError on any kind of failure.

§Examples
use std::path::Path;
use mpeg_audio_header::{Header, ParseMode};

let path = Path::new("test/source.mp3");
let header = Header::read_from_path(&path, ParseMode::PreferVbrHeaders).unwrap();
println!("MPEG audio header: {:?}", header);

Trait Implementations§

Source§

impl Clone for Header

Source§

fn clone(&self) -> Header

Returns a copy 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 Header

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl Freeze for Header

§

impl RefUnwindSafe for Header

§

impl Send for Header

§

impl Sync for Header

§

impl Unpin for Header

§

impl UnwindSafe for Header

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.