Builder

Struct Builder 

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

Builder of C LAME encoder.

Implementations§

Source§

impl Builder

Source

pub fn new() -> Option<Self>

Creates new encoder with default parameters: J-Stereo, 44.1khz 128kbps CBR mp3 file at quality 5

Returns None if unable to allocate struct.

Source

pub unsafe fn as_ptr(&mut self) -> *mut lame_global_flags

Get access to underlying LAME structure, without dropping ownership.

User must guarantee not to close or dealloc this pointer

Source

pub fn set_sample_rate(&mut self, rate: u32) -> Result<(), BuildError>

Sets sample rate.

Defaults to 44_100.

Returns whether it is supported or not.

Source

pub fn with_sample_rate(self, rate: u32) -> Result<Self, BuildError>

Sets sample rate using the builder pattern.

Defaults to 44_100.

Returns an error if it is not supported.

Source

pub fn set_num_channels(&mut self, num: u8) -> Result<(), BuildError>

Sets number of channels.

Defaults to 2.

Returns whether it is supported or not.

Source

pub fn with_num_channels(self, num: u8) -> Result<Self, BuildError>

Sets sample rate using the builder pattern.

Defaults to 2.

Returns an error if it is not supported.

Source

pub fn set_brate(&mut self, brate: Bitrate) -> Result<(), BuildError>

Sets bitrate (as kbps).

Defaults to compression ratio of 11.

Returns whether it is supported or not.

Source

pub fn with_brate(self, brate: Bitrate) -> Result<Self, BuildError>

Sets bitrate (as kbps) using the builder pattern.

Defaults to compression ratio of 11.

Returns an error if it is not supported.

Source

pub fn set_mode(&mut self, mode: Mode) -> Result<(), BuildError>

Sets MPEG mode.

Default is picked by LAME depending on compression ration and input channels.

Returns whether it is supported or not.

Source

pub fn with_mode(self, mode: Mode) -> Result<Self, BuildError>

Sets MPEG mode using the builder pattern.

Default is picked by LAME depending on compression ration and input channels.

Returns an error if it is not supported.

Source

pub fn set_quality(&mut self, quality: Quality) -> Result<(), BuildError>

Sets quality.

Default is good one(5)

Returns whether it is supported or not.

Source

pub fn with_quality(self, quality: Quality) -> Result<Self, BuildError>

Sets quality using the builder pattern.

Default is good one(5)

Returns an error if it is not supported.

Source

pub fn set_vbr_quality(&mut self, quality: Quality) -> Result<(), BuildError>

Sets VBR quality.

Returns whether it is supported or not.

Source

pub fn with_vbr_quality(self, quality: Quality) -> Result<Self, BuildError>

Sets VBR quality using the builder pattern.

Returns an error if it is not supported.

Source

pub fn set_to_write_vbr_tag(&mut self, value: bool) -> Result<(), BuildError>

Sets whether to write VBR tag.

Default is true.

Returns whether it is supported or not.

Source

pub fn with_to_write_vbr_tag(self, value: bool) -> Result<Self, BuildError>

Sets whether to write VBR tag using the builder pattern.

Default is true.

Returns an error if it is not supported.

Source

pub fn set_vbr_mode(&mut self, value: VbrMode) -> Result<(), BuildError>

Sets VBR mode.

Default is off (i.e. CBR)

Returns whether it is supported or not.

Source

pub fn with_vbr_mode(self, value: VbrMode) -> Result<Self, BuildError>

Sets VBR mode using the bulder pattern.

Default is off (i.e. CBR)

Returns an error if it is not supported.

Source

pub fn set_id3_tag(&mut self, value: Id3Tag<'_>) -> Result<(), Id3TagError>

Sets id3tag tag.

If FlushGap is used, then v1 will not be added. But v2 is always added at the beginning.

Returns whether it is supported or not.

Source

pub fn with_id3_tag(self, value: Id3Tag<'_>) -> Result<Self, Id3TagError>

Sets id3tag tag using the builder pattern.

If FlushGap is used, then v1 will not be added.

Returns an error if it is not supported.

Source

pub fn build(self) -> Result<Encoder, BuildError>

Attempts to initialize encoder with specified parameters.

Returns None if parameters are invalid or incompatible.

Trait Implementations§

Source§

impl Drop for Builder

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more

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.