Struct FlacEncoderUnmovable

Source
pub struct FlacEncoderUnmovable<'a, WriteSeek>
where WriteSeek: Write + Seek + Debug,
{ /* private fields */ }
Expand description
  • The flac encoder. The FlacEncoder is a wrapper for the FlacEncoderUnmovable what prevents the structure moves.

§The encoder’s core structure, but can’t move after initialize() has been called.

Use a Box to contain it, or just don’t move it will be fine.

Implementations§

Source§

impl<'a, WriteSeek> FlacEncoderUnmovable<'a, WriteSeek>
where WriteSeek: Write + Seek + Debug,

Source

pub fn new( writer: WriteSeek, on_write: Box<dyn FnMut(&mut WriteSeek, &[u8]) -> Result<(), Error> + 'a>, on_seek: Box<dyn FnMut(&mut WriteSeek, u64) -> Result<(), Error> + 'a>, on_tell: Box<dyn FnMut(&mut WriteSeek) -> Result<u64, Error> + 'a>, params: &FlacEncoderParams, ) -> Result<Self, FlacEncoderError>

Source

pub fn get_status_as_result( &self, function: &'static str, ) -> Result<(), FlacEncoderError>

  • If the status code is ok then return Ok(()) else return Err()
Source

pub fn get_status_as_error( &self, function: &'static str, ) -> Result<(), FlacEncoderError>

  • Regardless of the status code, just return it as an Err()
Source

pub fn as_ptr(&self) -> *const Self

  • The pointer to the struct, as client_data to be transferred to a field of the libFLAC encoder private_ struct.
  • All of the callback functions need the client_data to retrieve self, and libFLAC forgot to provide a function for us to change the client_data
  • That’s why our struct is Unmovable
Source

pub fn as_mut_ptr(&mut self) -> *mut Self

  • The pointer to the struct, as client_data to be transferred to a field of the libFLAC encoder private_ struct.
  • All of the callback functions need the client_data to retrieve self, and libFLAC forgot to provide a function for us to change the client_data
  • That’s why our struct is Unmovable
Source

pub fn insert_comments( &mut self, key: &'static str, value: &str, ) -> Result<(), FlacEncoderInitError>

  • Insert a metadata key-value pair before calling to initialize()
Source

pub fn insert_cue_sheet( &mut self, cue_sheet: &FlacCueSheet, ) -> Result<(), FlacEncoderInitError>

  • Insert a cue sheet before calling to initialize()
Source

pub fn add_picture( &mut self, picture_binary: &[u8], description: &str, mime_type: &str, width: u32, height: u32, depth: u32, colors: u32, ) -> Result<(), FlacEncoderInitError>

  • Add a picture before calling to initialize()
Source

pub fn inherit_metadata_from_id3( &mut self, tag: &Tag, ) -> Result<(), FlacEncoderInitError>

Source

pub fn initialize(&mut self) -> Result<(), FlacEncoderError>

  • The initialize() function. Sets up all of the callback functions, transfers all of the metadata to the encoder, and then sets client_data to the address of the self struct.
Source

pub fn get_params(&self) -> FlacEncoderParams

  • Retrieve the params from the encoder where you provided it for the creation of the encoder.
Source

pub fn tell(&mut self) -> Result<u64, Error>

  • Calls your on_tell() closure to get the current writing position.
Source

pub fn write_interleaved_samples( &mut self, samples: &[i32], ) -> Result<(), FlacEncoderError>

  • Encode the interleaved samples (interleaved by channels)
  • See FlacEncoderParams for the information on how to provide your samples in the [i32] array.
Source

pub fn write_mono_channel( &mut self, monos: &[i32], ) -> Result<(), FlacEncoderError>

  • Encode mono audio. Regardless of the channel setting of the FLAC encoder, the sample will be duplicated to the number of channels to accomplish the encoding
  • See FlacEncoderParams for the information on how to provide your samples in the [i32] array.
Source

pub fn write_stereos( &mut self, stereos: &[(i32, i32)], ) -> Result<(), FlacEncoderError>

  • Encode stereo audio, if the channels of the encoder are mono, the stereo samples will be turned to mono samples to encode.
  • If the channels of the encoder are stereo, then the samples will be encoded as it is.
  • If the encoder is multi-channel other than mono and stereo, an error is returned.
  • See FlacEncoderParams for the information on how to provide your samples in the i32 way.
Source

pub fn write_monos( &mut self, monos: &[Vec<i32>], ) -> Result<(), FlacEncoderError>

  • Encode multiple mono channels into the multi-channel encoder.
  • See FlacEncoderParams for the information on how to provide your samples in the i32 way.
Source

pub fn write_frames( &mut self, frames: &[Vec<i32>], ) -> Result<(), FlacEncoderError>

  • Encode samples by the audio frame array. Each audio frame contains one sample for every channel.
  • See FlacEncoderParams for the information on how to provide your samples in the i32 way.
Source

pub fn finish(&mut self) -> Result<(), FlacEncoderError>

  • After sending all of the samples to encode, must call finish() to complete encoding.
Source

pub fn finalize(self)

  • Call this function if you don’t want the encoder anymore.

Trait Implementations§

Source§

impl<'a, WriteSeek> Debug for FlacEncoderUnmovable<'_, WriteSeek>
where WriteSeek: Write + Seek + Debug,

Source§

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

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

impl<'a, WriteSeek> Drop for FlacEncoderUnmovable<'_, WriteSeek>
where WriteSeek: Write + Seek + Debug,

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more

Auto Trait Implementations§

§

impl<'a, WriteSeek> Freeze for FlacEncoderUnmovable<'a, WriteSeek>
where WriteSeek: Freeze,

§

impl<'a, WriteSeek> !RefUnwindSafe for FlacEncoderUnmovable<'a, WriteSeek>

§

impl<'a, WriteSeek> !Send for FlacEncoderUnmovable<'a, WriteSeek>

§

impl<'a, WriteSeek> !Sync for FlacEncoderUnmovable<'a, WriteSeek>

§

impl<'a, WriteSeek> Unpin for FlacEncoderUnmovable<'a, WriteSeek>
where WriteSeek: Unpin,

§

impl<'a, WriteSeek> !UnwindSafe for FlacEncoderUnmovable<'a, WriteSeek>

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> 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, 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.