### Get Stream Information in Rust Source: https://docs.rs/fdk-aac/latest/fdk_aac/dec/struct.Decoder.html?search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E Returns a reference to the `StreamInfo` struct, which contains details about the audio stream being decoded, such as sample rate and channel count. ```rust pub fn stream_info(&self) -> &StreamInfo ``` -------------------------------- ### Get Decoded Frame Size in Rust Source: https://docs.rs/fdk-aac/latest/fdk_aac/dec/struct.Decoder.html?search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E Retrieves the size of the decoded audio frame in bytes. This information is useful for pre-allocating buffers for decoded audio data. ```rust pub fn decoded_frame_size(&self) -> usize ``` -------------------------------- ### Initialize and Configure fdk-aac Decoder Source: https://docs.rs/fdk-aac/latest/fdk_aac/dec/struct.Decoder.html Demonstrates how to instantiate a new Decoder and configure its parameters such as raw audio specifications and output channel constraints. ```rust use fdk_aac::dec::{Decoder, Transport}; // Initialize a new decoder let mut decoder = Decoder::new(Transport::Raw); // Configure with raw audio specific config let config = vec![0x12, 0x10]; decoder.config_raw(&config).expect("Failed to configure decoder"); // Set output channel constraints decoder.set_min_output_channels(1).unwrap(); decoder.set_max_output_channels(2).unwrap(); ``` -------------------------------- ### Initialize and Configure Decoder in Rust Source: https://docs.rs/fdk-aac/latest/fdk_aac/dec/struct.Decoder.html?search=u32+-%3E+bool Demonstrates the instantiation of the Decoder struct and the configuration of audio parameters. These methods are essential for setting up the decoding environment before processing audio data. ```Rust pub struct Decoder { /* private fields */ } impl Decoder { pub fn new(transport: Transport) -> Self; pub fn config_raw(&mut self, audio_specic_config: &[u8]) -> Result<(), DecoderError>; pub fn set_min_output_channels(&mut self, channels: usize) -> Result<(), DecoderError>; pub fn set_max_output_channels(&mut self, channels: usize) -> Result<(), DecoderError>; } ``` -------------------------------- ### Get DecoderError Message in Rust Source: https://docs.rs/fdk-aac/latest/fdk_aac/dec/struct.DecoderError.html?search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E This function, `message`, is implemented for DecoderError in Rust. It returns a static string slice representing the error message associated with a specific DecoderError instance. This is useful for providing human-readable explanations of decoding failures. ```rust pub fn message(&self) -> &'static str ``` -------------------------------- ### Initialize and Use fdk-aac Encoder Source: https://docs.rs/fdk-aac/latest/fdk_aac/enc/struct.Encoder.html?search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E Demonstrates the structure of the Encoder and its primary methods including initialization, retrieving encoder information, and performing audio encoding. ```rust pub struct Encoder { /* private fields */ } // Initialization let encoder = Encoder::new(params)?; // Get encoder info let info = encoder.info()?; // Encode audio data let encode_info = encoder.encode(&input_buffer, &mut output_buffer)?; ``` -------------------------------- ### Decoder Initialization and Configuration Source: https://docs.rs/fdk-aac/latest/fdk_aac/dec/struct.Decoder.html?search=u32+-%3E+bool Methods to initialize the decoder and configure output channels and raw audio parameters. ```APIDOC ## Decoder Initialization ### Description Methods to create a new decoder instance and configure raw audio settings or channel constraints. ### Methods - **new(transport: Transport)**: Creates a new Decoder instance. - **config_raw(audio_specic_config: &[u8])**: Configures the decoder with raw audio specific configuration. - **set_min_output_channels(channels: usize)**: Sets the minimum number of output channels. - **set_max_output_channels(channels: usize)**: Sets the maximum number of output channels. ``` -------------------------------- ### Initialize and Use fdk-aac Encoder Source: https://docs.rs/fdk-aac/latest/fdk_aac/enc/struct.Encoder.html Demonstrates how to instantiate the Encoder with parameters and perform audio encoding. The encode method processes i16 PCM input into an AAC-encoded byte buffer. ```rust use fdk_aac::enc::{Encoder, EncoderParams}; // Initialize the encoder let params = EncoderParams::default(); let encoder = Encoder::new(params)?; // Retrieve encoder info let info = encoder.info()?; // Encode PCM data let input: &[i16] = &[0; 1024]; let mut output: &mut [u8] = &mut [0; 2048]; let encode_info = encoder.encode(input, &mut output)?; ``` -------------------------------- ### Initialize and Configure fdk-aac Decoder in Rust Source: https://docs.rs/fdk-aac/latest/fdk_aac/dec/struct.Decoder.html?search=std%3A%3Avec Demonstrates the definition of the Decoder struct and its primary methods for initializing a new instance and configuring it with raw audio specifications. ```rust pub struct Decoder { /* private fields */ } impl Decoder { pub fn new(transport: Transport) -> Self; pub fn config_raw(&mut self, audio_specic_config: &[u8]) -> Result<(), DecoderError>; } ``` -------------------------------- ### Initialize and use fdk_aac Encoder Source: https://docs.rs/fdk-aac/latest/fdk_aac/enc/struct.Encoder.html?search=u32+-%3E+bool Demonstrates the instantiation of the Encoder struct and the signature for the encode method. The encode method takes a slice of i16 samples and writes the result to a mutable byte slice. ```rust pub struct Encoder { /* private fields */ } // Initialization pub fn new(params: EncoderParams) -> Result; // Encoding process pub fn encode(&self, input: &[i16], output: &mut [u8]) -> Result; ``` -------------------------------- ### Encoder Initialization Source: https://docs.rs/fdk-aac/latest/fdk_aac/enc/struct.Encoder.html?search=std%3A%3Avec Creates a new instance of the Encoder. This function takes EncoderParams as input, which likely configure the encoding settings, and returns a Result containing either the Encoder instance or an EncoderError. ```rust pub fn new(params: EncoderParams) -> Result ``` -------------------------------- ### Encoder Methods Source: https://docs.rs/fdk-aac/latest/fdk_aac/enc/struct.Encoder.html?search=u32+-%3E+bool Provides methods for creating an encoder, retrieving encoder information, and performing audio encoding. ```APIDOC ## impl Encoder ### Description Methods for interacting with the AAC encoder. ### `new(params: EncoderParams) -> Result` Creates a new `Encoder` instance with the specified parameters. - **Parameters** - `params` (EncoderParams) - The configuration parameters for the encoder. - **Returns** - `Result` - Ok containing the new `Encoder` instance on success, or an `EncoderError` on failure. ### `info(&self) -> Result` Retrieves information about the encoder's capabilities and configuration. - **Returns** - `Result` - Ok containing `InfoStruct` with encoder details on success, or an `EncoderError` on failure. ### `encode(&self, input: &[i16], output: &mut [u8]) -> Result` Encodes a chunk of audio input data into the output buffer. - **Parameters** - `input` (&[i16]) - A slice of 16-bit integer audio samples to encode. - `output` (&mut [u8]) - A mutable slice of bytes to store the encoded audio data. - **Returns** - `Result` - Ok containing `EncodeInfo` with details about the encoded data on success, or an `EncoderError` on failure. ``` -------------------------------- ### Implement CloneToUninit for T in Rust Source: https://docs.rs/fdk-aac/latest/fdk_aac/enc/enum.ChannelMode.html Provides an experimental, nightly-only implementation of CloneToUninit for types T that implement Clone. This is an unsafe operation for copying data to uninitialized memory. ```rust impl CloneToUninit for T where T: Clone { unsafe fn clone_to_uninit(&self, dest: *mut u8) { // ... implementation details ... } } ``` -------------------------------- ### Implement TryFrom and TryInto traits Source: https://docs.rs/fdk-aac/latest/fdk_aac/dec/struct.DecoderError.html?search= These traits provide a mechanism for performing fallible conversions between types. TryFrom defines the conversion logic from a source type, while TryInto provides the inverse conversion method using the TryFrom implementation. ```rust type Error = Infallible; fn try_from(value: U) -> Result>::Error> { // Implementation logic for conversion } impl TryInto for T where U: TryFrom { type Error = >::Error; fn try_into(self) -> Result>::Error> { U::try_from(self) } } ``` -------------------------------- ### Decode Audio Frames with fdk-aac Source: https://docs.rs/fdk-aac/latest/fdk_aac/dec/struct.Decoder.html Shows the process of feeding encoded data into the decoder buffer and retrieving decoded PCM frames. ```rust let encoded_data = vec![0u8; 1024]; let mut pcm_buffer = vec![0i16; 2048]; // Fill the decoder buffer with encoded data let bytes_consumed = decoder.fill(&encoded_data).expect("Failed to fill buffer"); // Decode a frame into the PCM buffer decoder.decode_frame(&mut pcm_buffer).expect("Decoding failed"); ``` -------------------------------- ### Implement Generic Traits for Any Type in Rust Source: https://docs.rs/fdk-aac/latest/fdk_aac/enc/enum.ChannelMode.html?search=std%3A%3Avec Demonstrates blanket implementations of various standard traits (like Any, Borrow, CloneToUninit, From, Into, ToOwned, TryFrom, TryInto) for any type T in Rust. These implementations often rely on the type T itself implementing certain traits. ```rust impl Any for T where T: 'static + ?Sized { fn type_id(&self) -> TypeId } impl Borrow for T where T: ?Sized { fn borrow(&self) -> &T } impl BorrowMut for T where T: ?Sized { fn borrow_mut(&mut self) -> &mut T } impl CloneToUninit for T where T: Clone { unsafe fn clone_to_uninit(&self, dest: *mut u8) } impl From for T { fn from(t: T) -> T } impl Into for T where U: From { fn into(self) -> U } impl ToOwned for T where T: Clone { type Owned = T; fn to_owned(&self) -> T fn clone_into(&self, target: &mut T) } impl TryFrom for T where U: Into { type Error = Infallible; fn try_from(value: U) -> Result>::Error> } impl TryInto for T where U: TryFrom { type Error = >::Error; fn try_into(self) -> Result>::Error> } ``` -------------------------------- ### Clone Implementation for StreamInfo (Rust) Source: https://docs.rs/fdk-aac/latest/fdk_aac/dec/struct.StreamInfo.html Provides the `clone` and `clone_from` methods for the StreamInfo struct, allowing for the creation of duplicate instances. This is useful for preserving state or passing copies of stream information. ```rust impl Clone for CStreamInfo { fn clone(&self) -> CStreamInfo; fn clone_from(&mut self, source: &Self); } ``` -------------------------------- ### Implement Any for T in Rust Source: https://docs.rs/fdk-aac/latest/fdk_aac/enc/enum.ChannelMode.html Demonstrates a blanket implementation of the Any trait for any type T that is 'static and sized. This is part of Rust's trait system for dynamic typing. ```rust impl Any for T where T: 'static + ?Sized { fn type_id(&self) -> TypeId { // ... implementation details ... } } ``` -------------------------------- ### Initialize Decoder in Rust Source: https://docs.rs/fdk-aac/latest/fdk_aac/dec/struct.Decoder.html?search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E Creates a new instance of the Decoder. It requires a `Transport` object to establish communication or data flow for the decoder. ```rust pub fn new(transport: Transport) -> Self ``` -------------------------------- ### Encoder Blanket Implementations Source: https://docs.rs/fdk-aac/latest/fdk_aac/enc/struct.Encoder.html?search=u32+-%3E+bool Shows blanket implementations for generic traits applied to the Encoder struct. ```APIDOC ## Blanket Implementations for Encoder ### `impl Any for T where T: 'static + ?Sized` #### `fn type_id(&self) -> TypeId` Gets the `TypeId` of `self`. ### `impl Borrow for T where T: ?Sized` #### `fn borrow(&self) -> &T` Immutably borrows from an owned value. ### `impl BorrowMut for T where T: ?Sized` #### `fn borrow_mut(&mut self) -> &mut T` Mutably borrows from an owned value. ### `impl From for T` #### `fn from(t: T) -> T` Returns the argument unchanged. ### `impl Into for T where U: From` #### `fn into(self) -> U` Calls `U::from(self)`. ### `impl TryFrom for T where U: Into` #### `type Error = Infallible` The type returned in the event of a conversion error. #### `fn try_from(value: U) -> Result>::Error>` Performs the conversion. ### `impl TryInto for T where U: TryFrom` #### `type Error = >::Error` The type returned in the event of a conversion error. #### `fn try_into(self) -> Result>::Error>` Performs the conversion. ``` -------------------------------- ### Decode Audio Frames with fdk-aac in Rust Source: https://docs.rs/fdk-aac/latest/fdk_aac/dec/struct.Decoder.html?search=std%3A%3Avec Shows the methods used to feed data into the decoder buffer and process individual frames into PCM output buffers. ```rust impl Decoder { pub fn fill(&mut self, data: &[u8]) -> Result; pub fn decode_frame(&mut self, pcm: &mut [i16]) -> Result<(), DecoderError>; pub fn decoded_frame_size(&self) -> usize; } ``` -------------------------------- ### Configure Raw Audio Specifications in Rust Source: https://docs.rs/fdk-aac/latest/fdk_aac/dec/struct.Decoder.html?search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E Sets the raw audio specifications for the decoder. This method takes a byte slice representing the audio configuration and returns a Result indicating success or a DecoderError. ```rust pub fn config_raw(&mut self, audio_specic_config: &[u8]) -> Result<(), DecoderError> ``` -------------------------------- ### Encoder Trait Implementations Source: https://docs.rs/fdk-aac/latest/fdk_aac/enc/struct.Encoder.html?search=u32+-%3E+bool Details the trait implementations for the Encoder struct, including Debug and various auto traits. ```APIDOC ## Trait Implementations for Encoder ### `impl Debug for Encoder` Provides a way to format the `Encoder` instance for debugging purposes. #### `fn fmt(&self, f: &mut Formatter<'_>) -> Result` Formats the value using the given formatter. ``` ```APIDOC ## Auto Trait Implementations for Encoder ### `impl Freeze for Encoder` ### `impl RefUnwindSafe for Encoder` ### `impl Send for Encoder` ### `impl Sync for Encoder` ### `impl Unpin for Encoder` ### `impl UnwindSafe for Encoder` ``` -------------------------------- ### DecoderError Blanket Implementations Source: https://docs.rs/fdk-aac/latest/fdk_aac/dec/struct.DecoderError.html?search=std%3A%3Avec Details on blanket implementations for DecoderError, including Any, Borrow, BorrowMut, CloneToUninit, From, Into, ToOwned, ToString, and TryFrom. ```APIDOC ## Blanket Implementations for DecoderError ### impl Any for T - **type_id(&self) -> TypeId**: Gets the `TypeId` of `self`. ### impl Borrow for T - **borrow(&self) -> &T**: Immutably borrows from an owned value. ### impl BorrowMut for T - **borrow_mut(&mut self) -> &mut T**: Mutably borrows from an owned value. ### impl CloneToUninit for T - **clone_to_uninit(&self, dest: *mut u8)**: Performs copy-assignment from `self` to `dest` (nightly-only experimental API). ### impl From for T - **from(t: T) -> T**: Returns the argument unchanged. ### impl Into for T - **into(self) -> U**: Calls `U::from(self)`. ### impl ToOwned for T - **Owned**: The resulting type after obtaining ownership. - **to_owned(&self) -> T**: Creates owned data from borrowed data, usually by cloning. - **clone_into(&self, target: &mut T)**: Uses borrowed data to replace owned data, usually by cloning. ### impl ToString for T - **to_string(&self) -> String**: Converts the given value to a `String`. ### impl TryFrom for T (Implementation for trying to convert from another type) ``` -------------------------------- ### Set Minimum Output Channels in Rust Source: https://docs.rs/fdk-aac/latest/fdk_aac/dec/struct.Decoder.html?search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E Configures the minimum number of output audio channels. This function returns a Result, signaling success or a DecoderError if the operation fails. ```rust pub fn set_min_output_channels(&mut self, channels: usize) -> Result<(), DecoderError> ``` -------------------------------- ### Try Convert Type from Another Type Source: https://docs.rs/fdk-aac/latest/fdk_aac/enc/struct.Encoder.html?search= Implements the TryFrom trait, enabling fallible conversions from one type to another. It returns a Result, indicating success or failure of the conversion. ```rust fn try_from(value: U) -> Result>::Error> ``` -------------------------------- ### Standard Library Blanket Implementations Source: https://docs.rs/fdk-aac/latest/fdk_aac/dec/struct.StreamInfo.html Common Rust blanket implementations available for types, including memory borrowing, cloning, and type conversion traits. These provide standard functionality like From, Into, and Borrow for generic types. ```rust impl Borrow for T where T: ?Sized { fn borrow(&self) -> &T { self } } impl From for T { fn from(t: T) -> T { t } } impl Into for T where U: From { fn into(self) -> U { U::from(self) } } ``` -------------------------------- ### Implement CloneToUninit for Generic Type T in Rust (Nightly) Source: https://docs.rs/fdk-aac/latest/fdk_aac/enc/enum.ChannelMode.html?search=u32+-%3E+bool Presents the nightly-only experimental API for `CloneToUninit`. This trait allows for copy-assignment from a value to uninitialized memory, requiring the source type `T` to implement `Clone`. ```rust unsafe impl CloneToUninit for T where T: Clone { unsafe fn clone_to_uninit(&self, dest: *mut u8); } ``` -------------------------------- ### Clone Implementation for StreamInfo in Rust Source: https://docs.rs/fdk-aac/latest/fdk_aac/dec/struct.StreamInfo.html?search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E Provides the `clone` method for the StreamInfo struct, allowing for the creation of a duplicate of an existing StreamInfo instance. This is useful for preserving or copying decoding state. ```rust impl Clone for CStreamInfo { fn clone(&self) -> CStreamInfo { // Implementation details omitted for brevity } fn clone_from(&mut self, source: &Self) { // Implementation details omitted for brevity } } ``` -------------------------------- ### Implement Debug for EncodeInfo in Rust Source: https://docs.rs/fdk-aac/latest/fdk_aac/enc/struct.EncodeInfo.html Provides a Debug implementation for the EncodeInfo struct, allowing it to be formatted for debugging purposes. This enables developers to easily inspect the state of EncodeInfo instances during development and troubleshooting. ```rust impl Debug for EncodeInfo { fn fmt(&self, f: &mut Formatter<'_>) -> Result { // Implementation details for formatting unimplemented!("fmt not implemented") } } ``` -------------------------------- ### DecoderError Trait Implementations Source: https://docs.rs/fdk-aac/latest/fdk_aac/dec/struct.DecoderError.html?search= This section covers the standard trait implementations for the DecoderError struct, including Clone, Debug, Display, PartialEq, Eq, and Copy. ```APIDOC ## Trait Implementations for DecoderError ### impl Clone for DecoderError - **clone(&self) -> DecoderError**: Returns a duplicate of the value. - **clone_from(&mut self, source: &Self)**: Performs copy-assignment from `source`. ### impl Debug for DecoderError - **fmt(&self, f: &mut Formatter<'_>) -> Result**: Formats the value using the given formatter. ### impl Display for DecoderError - **fmt(&self, f: &mut Formatter<'_>) -> Result**: Formats the value using the given formatter. ### impl PartialEq for DecoderError - **eq(&self, other: &DecoderError) -> bool**: Tests for `self` and `other` values to be equal. - **ne(&self, other: &Rhs) -> bool**: Tests for `!=`. ### impl Eq for DecoderError ### impl Copy for DecoderError ### impl StructuralPartialEq for DecoderError ``` -------------------------------- ### Rust Blanket Implementation: CloneToUninit Trait (Nightly Only) Source: https://docs.rs/fdk-aac/latest/fdk_aac/dec/struct.StreamInfo.html?search=u32+-%3E+bool Implements the experimental `CloneToUninit` trait for any type `T` that implements `Clone`. This nightly-only API performs copy-assignment from `self` to a raw pointer `dest`. ```rust impl CloneToUninit for T where T: Clone, { unsafe fn clone_to_uninit(&self, dest: *mut u8) } ``` -------------------------------- ### Implement Sync for EncodeInfo in Rust Source: https://docs.rs/fdk-aac/latest/fdk_aac/enc/struct.EncodeInfo.html Marks the EncodeInfo struct as `Sync`, indicating that references to EncodeInfo can be safely shared across threads. This auto-trait implementation is vital for concurrent access to EncodeInfo data, ensuring thread safety. ```rust impl Sync for EncodeInfo {} ``` -------------------------------- ### Implement PartialEq for DecoderError in Rust Source: https://docs.rs/fdk-aac/latest/fdk_aac/dec/struct.DecoderError.html?search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E This code illustrates the implementation of the `PartialEq` trait for `DecoderError` in Rust. It includes the `eq` method for checking equality and the `ne` method for checking inequality between two `DecoderError` instances. ```rust fn eq(&self, other: &DecoderError) -> bool fn ne(&self, other: &Rhs) -> bool ``` -------------------------------- ### Implement Clone for AACENC_InfoStruct (Rust) Source: https://docs.rs/fdk-aac/latest/fdk_aac/enc/struct.InfoStruct.html?search= Provides `clone` and `clone_from` methods for the `AACENC_InfoStruct` (which appears to be an alias or related type to `InfoStruct`). This allows for creating copies of the encoder configuration information. ```rust impl Clone for AACENC_InfoStruct { fn clone(&self) -> AACENC_InfoStruct { // ... implementation details ... } fn clone_from(&mut self, source: &Self) { // ... implementation details ... } } ``` -------------------------------- ### Implement Debug for EncodeInfo in Rust Source: https://docs.rs/fdk-aac/latest/fdk_aac/enc/struct.EncodeInfo.html?search=std%3A%3Avec Provides a `Debug` implementation for the `EncodeInfo` struct, allowing it to be formatted for debugging purposes. This enables printing `EncodeInfo` instances using the `{:?}` format specifier. ```rust impl Debug for EncodeInfo { fn fmt(&self, f: &mut Formatter<'_>) -> Result } ``` -------------------------------- ### Rust TryInto Trait Implementation Source: https://docs.rs/fdk-aac/latest/fdk_aac/dec/struct.DecoderError.html Illustrates the implementation of the `TryInto` trait in Rust. This trait is automatically implemented for any type `T` that implements `TryFrom`, providing a convenient way to perform fallible conversions using the `try_into()` method. ```rust impl TryInto for T where U: TryFrom, { type Error = >::Error; fn try_into(self) -> Result { U::try_from(self) } } ``` -------------------------------- ### Try Convert Type into Another Type Source: https://docs.rs/fdk-aac/latest/fdk_aac/enc/struct.Encoder.html?search= Implements the TryInto trait, enabling fallible conversions from the current type into another type. This relies on the TryFrom for U implementation. ```rust fn try_into(self) -> Result>::Error> ``` -------------------------------- ### Implement TryInto for T in Rust Source: https://docs.rs/fdk-aac/latest/fdk_aac/enc/struct.EncodeInfo.html Provides a blanket implementation of the `TryInto` trait for any type `T` where `U` implements `TryFrom`. This allows attempting to convert `T` into `U`, returning a `Result` that indicates success or failure. ```rust impl TryInto for T where U: TryFrom { type Error = >::Error; fn try_into(self) -> Result { U::try_from(self) } } ``` -------------------------------- ### DecoderError Blanket Implementations Source: https://docs.rs/fdk-aac/latest/fdk_aac/dec/struct.DecoderError.html?search= Lists blanket implementations for DecoderError, showcasing its compatibility with generic Rust features. ```APIDOC ## Blanket Implementations for DecoderError ### impl Any for T - **type_id(&self) -> TypeId**: Gets the `TypeId` of `self`. ### impl Borrow for T - **borrow(&self) -> &T**: Immutably borrows from an owned value. ### impl BorrowMut for T - **borrow_mut(&mut self) -> &mut T**: Mutably borrows from an owned value. ### impl CloneToUninit for T - **clone_to_uninit(&self, dest: *mut u8)**: Performs copy-assignment from `self` to `dest`. ### impl From for T - **from(t: T) -> T**: Returns the argument unchanged. ### impl Into for T - **into(self) -> U**: Calls `U::from(self)`. ### impl ToOwned for T - **Owned**: The resulting type after obtaining ownership. - **to_owned(&self) -> T**: Creates owned data from borrowed data, usually by cloning. - **clone_into(&self, target: &mut T)**: Uses borrowed data to replace owned data, usually by cloning. ### impl ToString for T - **to_string(&self) -> String**: Converts the given value to a `String`. ### impl TryFrom for T ``` -------------------------------- ### DecoderError Trait Implementations Source: https://docs.rs/fdk-aac/latest/fdk_aac/dec/struct.DecoderError.html?search=std%3A%3Avec Details on the trait implementations for the DecoderError enum, including Clone, Debug, Display, PartialEq, Eq, Copy, and StructuralPartialEq. ```APIDOC ## Trait Implementations for DecoderError ### impl Clone for DecoderError - **clone(&self) -> DecoderError**: Returns a duplicate of the value. - **clone_from(&mut self, source: &Self)**: Performs copy-assignment from `source`. ### impl Debug for DecoderError - **fmt(&self, f: &mut Formatter<'_>) -> Result**: Formats the value using the given formatter. ### impl Display for DecoderError - **fmt(&self, f: &mut Formatter<'_>) -> Result**: Formats the value using the given formatter. ### impl PartialEq for DecoderError - **eq(&self, other: &DecoderError) -> bool**: Tests for `self` and `other` values to be equal. - **ne(&self, other: &Rhs) -> bool**: Tests for `!=`. ### impl Copy for DecoderError (Marker trait indicating the type is copyable) ### impl Eq for DecoderError (Marker trait indicating the type implements total equality) ### impl StructuralPartialEq for DecoderError (Marker trait for structural equality comparison) ``` -------------------------------- ### Generic From Implementation Source: https://docs.rs/fdk-aac/latest/fdk_aac/enc/struct.Encoder.html?search=std%3A%3Avec A blanket implementation of the `From` trait for `T`, which simply returns the argument unchanged. This is a trivial conversion. ```rust fn from(t: T) -> T ``` -------------------------------- ### Decode Audio Frames in Rust Source: https://docs.rs/fdk-aac/latest/fdk_aac/dec/struct.Decoder.html?search=u32+-%3E+bool Provides methods for feeding raw data into the decoder and retrieving decoded PCM frames. The fill method buffers input data, while decode_frame processes the buffer into the provided PCM slice. ```Rust impl Decoder { pub fn fill(&mut self, data: &[u8]) -> Result; pub fn decode_frame(&mut self, pcm: &mut [i16]) -> Result<(), DecoderError>; pub fn decoded_frame_size(&self) -> usize; pub fn stream_info(&self) -> &StreamInfo; } ``` -------------------------------- ### Rust TryFrom Trait Implementation Source: https://docs.rs/fdk-aac/latest/fdk_aac/dec/struct.DecoderError.html Demonstrates the implementation of the `TryFrom` trait in Rust. This trait allows for fallible conversions from one type to another, returning a `Result` where the `Err` variant holds a specific error type. ```rust impl TryFrom for T where U: TryFrom, { type Error = >::Error; fn try_from(value: U) -> Result { U::try_from(value) } } ``` -------------------------------- ### Define InfoStruct for AAC Encoder Configuration (Rust) Source: https://docs.rs/fdk-aac/latest/fdk_aac/enc/struct.InfoStruct.html?search= Defines the `InfoStruct` which holds configuration details for the AAC encoder. This struct includes fields for buffer sizes, channel counts, frame length, codec delays, and configuration data. It is marked with `#[repr(C)]` for C compatibility. ```rust #[repr(C)] pub struct InfoStruct { pub maxOutBufBytes: u32, pub maxAncBytes: u32, pub inBufFillLevel: u32, pub inputChannels: u32, pub frameLength: u32, pub nDelay: u32, pub nDelayCore: u32, pub confBuf: [u8; 64], pub confSize: u32, } ``` -------------------------------- ### Implement Display for DecoderError in Rust Source: https://docs.rs/fdk-aac/latest/fdk_aac/dec/struct.DecoderError.html?search=std%3A%3Avec This snippet illustrates the implementation of the `Display` trait for the `DecoderError` struct in Rust. The `fmt` method is defined to provide a user-friendly string representation of the error. ```rust impl Display for DecoderError { fn fmt(&self, f: &mut Formatter<'_>) -> Result; } ``` -------------------------------- ### Generic Into Implementation Source: https://docs.rs/fdk-aac/latest/fdk_aac/enc/struct.Encoder.html?search=std%3A%3Avec A blanket implementation of the `Into` trait for `T`, which delegates to `U::from(self)`. This allows conversion between types where a `From` implementation exists. ```rust fn into(self) -> U ``` -------------------------------- ### Implement BorrowMut for T in Rust Source: https://docs.rs/fdk-aac/latest/fdk_aac/enc/enum.ChannelMode.html Illustrates a blanket implementation of the BorrowMut trait for any type T. This enables mutable borrowing of types. ```rust impl BorrowMut for T where T: ?Sized { fn borrow_mut(&mut self) -> &mut T { // ... implementation details ... } } ``` -------------------------------- ### Implement TryFrom for T in Rust Source: https://docs.rs/fdk-aac/latest/fdk_aac/enc/struct.EncodeInfo.html Provides a blanket implementation of the `TryFrom` trait for any type `T` where `U` implements `Into`. This allows attempting a conversion from `U` to `T`, returning a `Result` that indicates success or failure. ```rust use std::convert::Infallible; impl TryFrom for T where U: Into { type Error = Infallible; fn try_from(value: U) -> Result { Ok(value.into()) } } ``` -------------------------------- ### Implement Any Trait for Generic Type T in Rust Source: https://docs.rs/fdk-aac/latest/fdk_aac/enc/enum.ChannelMode.html?search=u32+-%3E+bool Demonstrates the blanket implementation of the `Any` trait for any type `T` that is `'static` and sized. This allows for runtime type identification using the `type_id` method. ```rust impl Any for T where T: 'static + ?Sized { fn type_id(&self) -> TypeId; } ``` -------------------------------- ### Blanket Implementations for EncoderError Source: https://docs.rs/fdk-aac/latest/fdk_aac/enc/struct.EncoderError.html?search= Details of blanket implementations available for EncoderError, such as Any, Borrow, From, Into, ToString, and TryFrom/TryInto. ```APIDOC ## Blanket Implementations ### impl Any for T #### fn type_id(&self) -> TypeId Gets the `TypeId` of `self`. ### impl Borrow for T #### fn borrow(&self) -> &T Immutably borrows from an owned value. ### impl BorrowMut for T #### fn borrow_mut(&mut self) -> &mut T Mutably borrows from an owned value. ### impl From for T #### fn from(t: T) -> T Returns the argument unchanged. ### impl Into for T #### fn into(self) -> U Calls `U::from(self)`. ### impl ToString for T #### fn to_string(&self) -> String Converts the given value to a `String`. ### impl TryFrom for T #### type Error = Infallible The type returned in the event of a conversion error. #### fn try_from(value: U) -> Result>::Error> Performs the conversion. ### impl TryInto for T #### type Error = >::Error The type returned in the event of a conversion error. #### fn try_into(self) -> Result>::Error> Performs the conversion. ``` -------------------------------- ### Transport Enum Documentation Source: https://docs.rs/fdk-aac/latest/fdk_aac/enc/enum.Transport.html?search=std%3A%3Avec This section details the Transport enum, its variants (Adts, Raw), and its implementations of various Rust traits. ```APIDOC ## Enum Transport ### Description Represents different transport methods for AAC audio data. ### Variants * **Adts**: Represents AAC data in ADTS (Audio Data Transport Stream) format. * **Raw**: Represents raw AAC audio data without any framing or headers. ### Trait Implementations #### `impl Debug for Transport` * **`fn fmt(&self, f: &mut Formatter<'_>) -> Result`**: Formats the value using the given formatter. #### Auto Trait Implementations * `impl Freeze for Transport` * `impl RefUnwindSafe for Transport` * `impl Send for Transport` * `impl Sync for Transport` * `impl Unpin for Transport` * `impl UnwindSafe for Transport` #### Blanket Implementations * `impl Any for T` * **`fn type_id(&self) -> TypeId`**: Gets the `TypeId` of `self`. * `impl Borrow for T` * **`fn borrow(&self) -> &T`**: Immutably borrows from an owned value. * `impl BorrowMut for T` * **`fn borrow_mut(&mut self) -> &mut T`**: Mutably borrows from an owned value. * `impl From for T` * **`fn from(t: T) -> T`**: Returns the argument unchanged. * `impl Into for T` * **`fn into(self) -> U`**: Calls `U::from(self)`. * `impl TryFrom for T` * **`type Error = Infallible`**: The type returned in the event of a conversion error. * **`fn try_from(value: U) -> Result>::Error>`**: Performs the conversion. * `impl TryInto for T` * **`type Error = >::Error`**: The type returned in the event of a conversion error. * **`fn try_into(self) -> Result>::Error>`**: Performs the conversion. ``` -------------------------------- ### Implement Copy and Eq for DecoderError in Rust Source: https://docs.rs/fdk-aac/latest/fdk_aac/dec/struct.DecoderError.html?search=std%3A%3Avec This snippet demonstrates the implementation of the `Copy` and `Eq` traits for the `DecoderError` struct in Rust. These traits indicate that the error type can be trivially copied and that equality comparison is total. ```rust impl Copy for DecoderError {} impl Eq for DecoderError {} ``` -------------------------------- ### Set Maximum Output Channels in Rust Source: https://docs.rs/fdk-aac/latest/fdk_aac/dec/struct.Decoder.html?search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E Sets the maximum number of output audio channels the decoder should produce. It returns a Result to indicate success or a DecoderError. ```rust pub fn set_max_output_channels(&mut self, channels: usize) -> Result<(), DecoderError> ``` -------------------------------- ### Implement Clone for AudioObjectType in Rust Source: https://docs.rs/fdk-aac/latest/fdk_aac/enc/enum.AudioObjectType.html?search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E Provides the `Clone` trait implementation for the `AudioObjectType` enum. This allows creating duplicate instances of an `AudioObjectType` value, ensuring that enum variants can be copied. ```rust impl Clone for AudioObjectType { fn clone(&self) -> AudioObjectType; fn clone_from(&mut self, source: &Self); } ``` -------------------------------- ### Implement Any for T in Rust Source: https://docs.rs/fdk-aac/latest/fdk_aac/enc/struct.EncodeInfo.html Provides a blanket implementation of the `Any` trait for any type `T` that is `'static` and not `?Sized`. This allows for runtime type identification and downcasting of any static type. ```rust impl Any for T { fn type_id(&self) -> TypeId { // Implementation details for type_id unimplemented!("type_id not implemented") } } ``` -------------------------------- ### Copy Implementation for StreamInfo in Rust Source: https://docs.rs/fdk-aac/latest/fdk_aac/dec/struct.StreamInfo.html?search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E Indicates that the StreamInfo struct implements the `Copy` trait. This means that instances of StreamInfo can be copied by simply copying their bits, which is efficient for small, simple data structures. ```rust impl Copy for CStreamInfo {} ``` -------------------------------- ### Implement Any Trait for Generic Types in Rust Source: https://docs.rs/fdk-aac/latest/fdk_aac/dec/struct.Decoder.html?search= Implements the Any trait for any type T that is 'static and ?Sized, allowing for runtime type identification. ```rust impl Any for T where T: 'static + ?Sized, ``` ```rust fn type_id(&self) -> TypeId ``` -------------------------------- ### Implement Debug for ChannelMode in Rust Source: https://docs.rs/fdk-aac/latest/fdk_aac/enc/enum.ChannelMode.html?search=std%3A%3Avec Implements the Debug trait for the ChannelMode enum, enabling formatted output for debugging purposes. The `fmt` method is used to write the enum's representation to a formatter. ```rust impl Debug for ChannelMode { fn fmt(&self, f: &mut Formatter<'_>) -> Result } ``` -------------------------------- ### EncoderParams Configuration Source: https://docs.rs/fdk-aac/latest/fdk_aac/enc/struct.EncoderParams.html?search=u32+-%3E+bool Defines the structure and fields required to configure the FDK-AAC encoder instance. ```APIDOC ## EncoderParams Configuration ### Description The `EncoderParams` struct is used to define the encoding settings for the FDK-AAC encoder. It encapsulates the necessary parameters to initialize the audio encoding process. ### Method N/A (Rust Struct Definition) ### Parameters #### Request Body - **bit_rate** (BitRate) - Required - The target bit rate for the AAC stream. - **sample_rate** (u32) - Required - The audio sample rate in Hz. - **transport** (Transport) - Required - The transport format (e.g., ADTS, RAW). - **channels** (ChannelMode) - Required - The channel configuration (e.g., Mono, Stereo). - **audio_object_type** (AudioObjectType) - Required - The MPEG-4 Audio Object Type (e.g., AAC-LC, HE-AAC). ### Request Example { "bit_rate": "BitRate::Cbr(128000)", "sample_rate": 44100, "transport": "Transport::Adts", "channels": "ChannelMode::Stereo", "audio_object_type": "AudioObjectType::AacLc" } ``` -------------------------------- ### Implement Clone for ChannelMode in Rust Source: https://docs.rs/fdk-aac/latest/fdk_aac/enc/enum.ChannelMode.html?search=std%3A%3Avec Provides implementations for the Clone trait for the ChannelMode enum. This allows instances of ChannelMode to be duplicated. It includes methods for `clone` and `clone_from`. ```rust impl Clone for ChannelMode { fn clone(&self) -> ChannelMode fn clone_from(&mut self, source: &Self) } ``` -------------------------------- ### Generic TryInto Implementation Source: https://docs.rs/fdk-aac/latest/fdk_aac/enc/struct.Encoder.html?search=std%3A%3Avec A blanket implementation of the `TryInto` trait for `T`. It attempts to convert `self` into `U` using `U::try_from(self)`. The error type is determined by the `TryFrom` implementation. ```rust type Error = >::Error fn try_into(self) -> Result>::Error> ``` -------------------------------- ### EncoderError Trait Implementations Source: https://docs.rs/fdk-aac/latest/fdk_aac/enc/struct.EncoderError.html?search= Documentation for the trait implementations of EncoderError, including Debug, Display, and Auto Trait Implementations. ```APIDOC ## Trait Implementations for EncoderError ### impl Debug for EncoderError #### fn fmt(&self, f: &mut Formatter<'_>) -> Result Formats the value using the given formatter. ### impl Display for EncoderError #### fn fmt(&self, f: &mut Formatter<'_>) -> Result Formats the value using the given formatter. ### Auto Trait Implementations - `Freeze` - `RefUnwindSafe` - `Send` - `Sync` - `Unpin` - `UnwindSafe` ``` -------------------------------- ### Decoder Processing Methods Source: https://docs.rs/fdk-aac/latest/fdk_aac/dec/struct.Decoder.html?search=u32+-%3E+bool Methods for feeding data into the decoder and retrieving decoded PCM frames. ```APIDOC ## Decoder Processing ### Description Methods used to pass encoded data into the decoder and extract the resulting PCM audio frames. ### Methods - **fill(data: &[u8]) -> Result**: Feeds encoded data into the decoder buffer. - **decode_frame(pcm: &mut [i16]) -> Result<(), DecoderError>**: Decodes a single frame into the provided PCM buffer. - **decoded_frame_size() -> usize**: Returns the expected size of the decoded frame. - **stream_info() -> &StreamInfo**: Retrieves metadata about the current audio stream. ``` -------------------------------- ### Implement Clone for ChannelMode in Rust Source: https://docs.rs/fdk-aac/latest/fdk_aac/enc/enum.ChannelMode.html?search=u32+-%3E+bool Provides implementations for the Clone trait for the ChannelMode enum. This allows creating duplicate instances of ChannelMode values, including `clone` and `clone_from` methods. ```rust impl Clone for ChannelMode { fn clone(&self) -> ChannelMode; fn clone_from(&mut self, source: &Self); } ``` -------------------------------- ### Format Decoder for Debugging in Rust Source: https://docs.rs/fdk-aac/latest/fdk_aac/dec/struct.Decoder.html?search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E Implements the `Debug` trait for the `Decoder` struct, allowing it to be formatted for debugging output. This is crucial for inspecting the decoder's state. ```rust fn fmt(&self, f: &mut Formatter<'_>) -> Result ``` -------------------------------- ### Implement Send for EncodeInfo in Rust Source: https://docs.rs/fdk-aac/latest/fdk_aac/enc/struct.EncodeInfo.html Marks the EncodeInfo struct as `Send`, indicating that it can be safely transferred between threads. This auto-trait implementation is essential for concurrent programming, allowing EncodeInfo instances to be shared or moved across different threads. ```rust impl Send for EncodeInfo {} ``` -------------------------------- ### Generic Blanket Implementations for T in Rust Source: https://docs.rs/fdk-aac/latest/fdk_aac/dec/struct.DecoderError.html?search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E This section details various blanket implementations for generic types `T` in Rust, which also apply to `DecoderError`. These include implementations for `Any`, `Borrow`, `BorrowMut`, `CloneToUninit`, `From`, `Into`, `ToOwned`, and `ToString`. These traits provide fundamental functionalities like type identification, borrowing, cloning, conversions, and string representation. ```rust impl Any for T impl Borrow for T impl BorrowMut for T impl CloneToUninit for T impl From for T impl Into for T impl ToOwned for T impl ToString for T impl TryFrom for T ``` -------------------------------- ### Fill Decoder Buffer in Rust Source: https://docs.rs/fdk-aac/latest/fdk_aac/dec/struct.Decoder.html?search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E Fills the decoder's internal buffer with input data. It takes a byte slice and returns the number of bytes processed or a DecoderError. ```rust pub fn fill(&mut self, data: &[u8]) -> Result ``` -------------------------------- ### Implement Debug for AudioObjectType in Rust Source: https://docs.rs/fdk-aac/latest/fdk_aac/enc/enum.AudioObjectType.html?search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E Implements the `Debug` trait for the `AudioObjectType` enum, enabling formatted output for debugging purposes. This allows developers to print `AudioObjectType` values in a human-readable format. ```rust impl Debug for AudioObjectType { fn fmt(&self, f: &mut Formatter<'_>) -> Result; } ``` -------------------------------- ### Standard Blanket Trait Implementations Source: https://docs.rs/fdk-aac/latest/fdk_aac/dec/struct.StreamInfo.html?search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E Common Rust blanket implementations for generic types, including memory borrowing, cloning, and type conversion traits. These are automatically available for types that satisfy the trait bounds. ```rust impl Borrow for T { fn borrow(&self) -> &T { self } } impl From for T { fn from(t: T) -> T { t } } impl Into for T where U: From { fn into(self) -> U { U::from(self) } } ``` -------------------------------- ### Implement Any Trait for Generic Types in Rust Source: https://docs.rs/fdk-aac/latest/fdk_aac/dec/struct.Decoder.html?search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E Implements the `Any` trait for any type `T` that is `'static` and not `?Sized`. This allows for runtime type identification. ```rust impl Any for T where T: 'static + ?Sized ``` -------------------------------- ### Implement Sync Trait for Decoder in Rust Source: https://docs.rs/fdk-aac/latest/fdk_aac/dec/struct.Decoder.html?search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E Indicates that the `Decoder` struct is safe to be shared between threads. This is an auto-trait implementation. ```rust impl Sync for Decoder ``` -------------------------------- ### Generic TryFrom Implementation Source: https://docs.rs/fdk-aac/latest/fdk_aac/enc/struct.Encoder.html?search=std%3A%3Avec A blanket implementation of the `TryFrom` trait for `T`. It attempts to convert `U` into `T` using `U::into(self)`. The error type is `Infallible`. ```rust type Error = Infallible fn try_from(value: U) -> Result>::Error> ``` -------------------------------- ### Implement Clone for ChannelMode in Rust Source: https://docs.rs/fdk-aac/latest/fdk_aac/enc/enum.ChannelMode.html Provides implementations for the Clone trait for the ChannelMode enum. This allows for creating duplicate values of ChannelMode instances. ```rust impl Clone for ChannelMode { fn clone(&self) -> ChannelMode { // ... implementation details ... } fn clone_from(&mut self, source: &Self) { // ... implementation details ... } } ``` -------------------------------- ### Debug Implementation for StreamInfo (Rust) Source: https://docs.rs/fdk-aac/latest/fdk_aac/dec/struct.StreamInfo.html Implements the `Debug` trait for the StreamInfo struct, enabling formatted output for debugging purposes. This allows developers to easily inspect the contents of a StreamInfo object. ```rust impl Debug for CStreamInfo { fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>; } ``` -------------------------------- ### Implement Debug for DecoderError in Rust Source: https://docs.rs/fdk-aac/latest/fdk_aac/dec/struct.DecoderError.html?search=std%3A%3Avec This snippet shows the implementation of the `Debug` trait for the `DecoderError` struct in Rust. The `fmt` method is provided to format the error for debugging purposes. ```rust impl Debug for DecoderError { fn fmt(&self, f: &mut Formatter<'_>) -> Result; } ``` -------------------------------- ### Implement Borrow for T in Rust Source: https://docs.rs/fdk-aac/latest/fdk_aac/enc/enum.ChannelMode.html Shows a blanket implementation of the Borrow trait for any type T. This allows types to be borrowed immutably. ```rust impl Borrow for T where T: ?Sized { fn borrow(&self) -> &T { // ... implementation details ... } } ``` -------------------------------- ### Generic Blanket Implementations for T in Rust Source: https://docs.rs/fdk-aac/latest/fdk_aac/dec/struct.DecoderError.html?search=std%3A%3Avec This snippet shows various blanket implementations for generic types `T` in Rust, including `Any`, `Borrow`, `BorrowMut`, `CloneToUninit`, `From`, `Into`, `ToOwned`, and `ToString`. These are common trait implementations provided by the Rust standard library. ```rust impl Any for T where T: 'static + ?Sized { fn type_id(&self) -> TypeId; } impl Borrow for T where T: ?Sized { fn borrow(&self) -> &T; } impl BorrowMut for T where T: ?Sized { fn borrow_mut(&mut self) -> &mut T; } impl CloneToUninit for T where T: Clone { unsafe fn clone_to_uninit(&self, dest: *mut u8); } impl From for T { fn from(t: T) -> T; } impl Into for T where U: From { fn into(self) -> U; } impl ToOwned for T where T: Clone { type Owned = T; fn to_owned(&self) -> T; fn clone_into(&self, target: &mut T); } impl ToString for T where T: Display + ?Sized { fn to_string(&self) -> String; } impl TryFrom for T where U: Into {} ``` -------------------------------- ### Implement Unpin for EncodeInfo in Rust Source: https://docs.rs/fdk-aac/latest/fdk_aac/enc/struct.EncodeInfo.html Marks the EncodeInfo struct as `Unpin`, indicating that its memory layout is stable and does not require special handling for pinning. This auto-trait implementation simplifies memory management and interaction with asynchronous runtimes. ```rust impl Unpin for EncodeInfo {} ```