pub struct FlacEncoderUnmovable<'a, WriteSeek>{ /* private fields */ }
Expand description
- The flac encoder. The
FlacEncoder
is a wrapper for theFlacEncoderUnmovable
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>
impl<'a, WriteSeek> FlacEncoderUnmovable<'a, WriteSeek>
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>
Sourcepub fn get_status_as_result(
&self,
function: &'static str,
) -> Result<(), FlacEncoderError>
pub fn get_status_as_result( &self, function: &'static str, ) -> Result<(), FlacEncoderError>
- If the status code is ok then return
Ok(())
else returnErr()
Sourcepub fn get_status_as_error(
&self,
function: &'static str,
) -> Result<(), FlacEncoderError>
pub fn get_status_as_error( &self, function: &'static str, ) -> Result<(), FlacEncoderError>
- Regardless of the status code, just return it as an
Err()
Sourcepub fn as_ptr(&self) -> *const Self
pub fn as_ptr(&self) -> *const Self
- The pointer to the struct, as
client_data
to be transferred to a field of the libFLAC encoderprivate_
struct. - All of the callback functions need the
client_data
to retrieveself
, and libFLAC forgot to provide a function for us to change theclient_data
- That’s why our struct is
Unmovable
Sourcepub fn as_mut_ptr(&mut self) -> *mut Self
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 encoderprivate_
struct. - All of the callback functions need the
client_data
to retrieveself
, and libFLAC forgot to provide a function for us to change theclient_data
- That’s why our struct is
Unmovable
Sourcepub fn insert_comments(
&mut self,
key: &'static str,
value: &str,
) -> Result<(), FlacEncoderInitError>
pub fn insert_comments( &mut self, key: &'static str, value: &str, ) -> Result<(), FlacEncoderInitError>
- Insert a metadata key-value pair before calling to
initialize()
Sourcepub fn insert_cue_sheet(
&mut self,
cue_sheet: &FlacCueSheet,
) -> Result<(), FlacEncoderInitError>
pub fn insert_cue_sheet( &mut self, cue_sheet: &FlacCueSheet, ) -> Result<(), FlacEncoderInitError>
- Insert a cue sheet before calling to
initialize()
Sourcepub fn add_picture(
&mut self,
picture_binary: &[u8],
description: &str,
mime_type: &str,
width: u32,
height: u32,
depth: u32,
colors: u32,
) -> Result<(), FlacEncoderInitError>
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()
pub fn inherit_metadata_from_id3( &mut self, tag: &Tag, ) -> Result<(), FlacEncoderInitError>
Sourcepub fn initialize(&mut self) -> Result<(), FlacEncoderError>
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 setsclient_data
to the address of theself
struct.
Sourcepub fn get_params(&self) -> FlacEncoderParams
pub fn get_params(&self) -> FlacEncoderParams
- Retrieve the params from the encoder where you provided it for the creation of the encoder.
Sourcepub fn tell(&mut self) -> Result<u64, Error>
pub fn tell(&mut self) -> Result<u64, Error>
- Calls your
on_tell()
closure to get the current writing position.
Sourcepub fn write_interleaved_samples(
&mut self,
samples: &[i32],
) -> Result<(), FlacEncoderError>
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.
Sourcepub fn write_mono_channel(
&mut self,
monos: &[i32],
) -> Result<(), FlacEncoderError>
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.
Sourcepub fn write_stereos(
&mut self,
stereos: &[(i32, i32)],
) -> Result<(), FlacEncoderError>
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 thei32
way.
Sourcepub fn write_monos(
&mut self,
monos: &[Vec<i32>],
) -> Result<(), FlacEncoderError>
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 thei32
way.
Sourcepub fn write_frames(
&mut self,
frames: &[Vec<i32>],
) -> Result<(), FlacEncoderError>
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 thei32
way.
Sourcepub fn finish(&mut self) -> Result<(), FlacEncoderError>
pub fn finish(&mut self) -> Result<(), FlacEncoderError>
- After sending all of the samples to encode, must call
finish()
to complete encoding.
Trait Implementations§
Source§impl<'a, WriteSeek> Debug for FlacEncoderUnmovable<'_, WriteSeek>
impl<'a, WriteSeek> Debug for FlacEncoderUnmovable<'_, WriteSeek>
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> 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