Encoder

Struct Encoder 

Source
pub struct Encoder { /* private fields */ }
Expand description

LAME Encoder.

Implementations§

Source§

impl Encoder

Source

pub fn sample_rate(&self) -> u32

Returns sample rate.

Source

pub fn num_channels(&self) -> u8

Returns number of channels.

Source

pub fn encode( &mut self, input: impl EncoderInput, output: &mut [MaybeUninit<u8>], ) -> Result<usize, EncodeError>

Attempts to encode PCM data, writing whatever available onto output buffer

§Arguments:
§Result:

On success, returns number of bytes written (can be 0). Otherwise returns error indicating potential issue.

Source

pub fn encode_to_vec( &mut self, input: impl EncoderInput, output: &mut Vec<u8>, ) -> Result<usize, EncodeError>

Attempts to encode PCM data, writing whatever available onto output buffer

output size is adjusted on success only

Refer for details to encode()

Source

pub fn flush<T: EncoderFlush>( &mut self, output: &mut [MaybeUninit<u8>], ) -> Result<usize, EncodeError>

Attempts flush all data, writing whatever available onto output buffer Padding with 0 to complete MP3

§Type:
  • FlushNoGap - performs flush, using ancillary data to fill gaps;
  • FlushGap - performs flush, padding with 0;
§Arguments:
  • output - Output buffer to write into. As it is final action, you need at least 7200 bytes to hold at MP3 data.
§Result:

On success, returns number of bytes written (can be 0). Otherwise returns error indicating potential issue.

Source

pub fn flush_to_vec<T: EncoderFlush>( &mut self, output: &mut Vec<u8>, ) -> Result<usize, EncodeError>

Attempts flush all data, writing whatever available onto output buffer.

output size is adjusted on success only

Refer for details to flush()

Trait Implementations§

Source§

impl Drop for Encoder

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

impl Send for Encoder

According to LAME 3.99.5 HACKING, it is thread-safe.

Source§

impl Sync for Encoder

According to LAME 3.99.5 HACKING, it is thread-safe.

Auto Trait Implementations§

Blanket Implementations§

§

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

§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

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

§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
§

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

§

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

Mutably borrows from an owned value. Read more
§

impl<T> From<T> for T

§

fn from(t: T) -> T

Returns the argument unchanged.

§

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

§

fn into(self) -> U

Calls U::from(self).

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

§

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

§

type Error = Infallible

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

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

Performs the conversion.
§

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

§

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

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

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

Performs the conversion.