### Getting Underlying Bits of Flags Source: https://docs.rs/ffmpeg-the-third/latest/ffmpeg_the_third/util/option/struct.Type_search= Retrieves the raw underlying bits value of the flags. This can be useful for low-level manipulation or interoperation with C APIs. ```rust fn bits(&self) -> c_uint ``` -------------------------------- ### Blanket Implementations Source: https://docs.rs/ffmpeg-the-third/latest/ffmpeg_the_third/util/option/struct.Type_search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E Details blanket implementations for `Any`, `Borrow`, `BorrowMut`, and `CloneToUninit`. ```APIDOC ## Blanket Implementations ### `Any` for `T` - **`type_id`**: Gets the `TypeId` of `self`. ### `Borrow` for `T` - **`borrow`**: Immutably borrows from an owned value. ### `BorrowMut` for `T` - **`borrow_mut`**: Mutably borrows from an owned value. ### `CloneToUninit` for `T` (Nightly-only experimental API) - **`clone_to_uninit`**: Performs copy-assignment from `self` to `dest`. ``` -------------------------------- ### Blanket Implementations: Any, Borrow, CloneToUninit Source: https://docs.rs/ffmpeg-the-third/latest/ffmpeg_the_third/util/option/struct.Type_search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E Shows blanket implementations for generic traits like `Any` for runtime type identification, `Borrow` and `BorrowMut` for shared and mutable access, and `CloneToUninit` for experimental cloning to uninitialized memory. ```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) ``` -------------------------------- ### Blanket Implementations (Any, Borrow, CloneToUninit) Source: https://docs.rs/ffmpeg-the-third/latest/ffmpeg_the_third/util/option/struct.Type_search= Covers blanket implementations provided by the standard library, such as `Any`, `Borrow`, and `CloneToUninit`. ```APIDOC ### impl Any for T ### Description Allows the type to be downcast from a trait object. ### Method `type_id` ### Returns - **TypeId**: The unique identifier for the type. ### impl Borrow for T ### Description Allows borrowing the type itself immutably. ### Method `borrow` ### Returns - **&T**: An immutable reference to the type. ### impl BorrowMut for T ### Description Allows borrowing the type itself mutably. ### Method `borrow_mut` ### Returns - **&mut T**: A mutable reference to the type. ### impl CloneToUninit for T ### Description (Nightly-only experimental API) Allows cloning the type into uninitialized memory. ### Method `clone_to_uninit` ### Safety - **unsafe**: This method is unsafe and requires careful handling of memory. ``` -------------------------------- ### Ordering and Comparison Implementations Source: https://docs.rs/ffmpeg-the-third/latest/ffmpeg_the_third/util/option/struct.Type_search= Details on how FFmpeg types can be ordered and compared. ```APIDOC ## Ord for Type ### Description Provides a total ordering for the type. ### Method `cmp` ### Parameters - **other** (Type) - The other value to compare against. ### Return Type - **Result** (Ordering) - An `Ordering` between `self` and `other`. ### Methods - **`max(self, other: Self) -> Self`**: Compares and returns the maximum of two values. - **`min(self, other: Self) -> Self`**: Compares and returns the minimum of two values. - **`clamp(self, min: Self, max: Self) -> Self`**: Restricts a value to a certain interval. ## PartialOrd for Type ### Description Provides a partial ordering for the type, allowing for comparisons that may not always yield a result (e.g., NaN). ### Method `partial_cmp` ### Parameters - **other** (Type) - The other value to compare against. ### Return Type - **Option** - An `Option` containing an `Ordering` if one exists. ### Methods - **`lt(&self, other: &Rhs) -> bool`**: Tests less than (`<`). - **`le(&self, other: &Rhs) -> bool`**: Tests less than or equal to (`<=`). - **`gt(&self, other: &Rhs) -> bool`**: Tests greater than (`>`). - **`ge(&self, other: &Rhs) -> bool`**: Tests greater than or equal to (`>=`). ``` -------------------------------- ### Type Conversions and Iteration Source: https://docs.rs/ffmpeg-the-third/latest/ffmpeg_the_third/util/option/struct.Type_search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E Covers conversions to and from AVOptionType, creating iterators, and converting values into iterators. ```APIDOC ## Type Conversions and Iteration ### `From` for `Type` Converts to `Type` from `AVOptionType`. ### `From` for `AVOptionType` Converts to `AVOptionType` from `Type`. ### `FromIterator` for `Type` The bitwise or (`|`) of the bits in each flags value. ### `IntoIterator` for `Type` - **Item**: `Type` (The type of the elements being iterated over.) - **IntoIter**: `Iter` (The type of the iterator.) Creates an iterator from a value. ``` -------------------------------- ### Comparison and Equality Source: https://docs.rs/ffmpeg-the-third/latest/ffmpeg_the_third/util/option/struct.Type_search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E Documents the trait implementations for ordering, partial ordering, equality, and partial equality comparisons. ```APIDOC ## Comparison and Equality ### `Ord` for `Type` - **`cmp`**: Compares `self` and `other` and returns an `Ordering`. - **`max`**: Compares and returns the maximum of two values. - **`min`**: Compares and returns the minimum of two values. - **`clamp`**: Restricts a value to a certain interval. ### `PartialOrd` for `Type` - **`partial_cmp`**: Returns an ordering between `self` and `other` if one exists. - **`lt`**: Tests less than. - **`le`**: Tests less than or equal to. - **`gt`**: Tests greater than. - **`ge`**: Tests greater than or equal to. ### `PartialEq` for `Type` - **`eq`**: Tests for equality (`==`). - **`ne`**: Tests for inequality (`!=`). ### `Eq` for `Type` Indicates that `Type` implements `PartialEq` and its equality relation is reflexive, symmetric, and transitive. ``` -------------------------------- ### Rust Type Conversions (From and FromIterator) Source: https://docs.rs/ffmpeg-the-third/latest/ffmpeg_the_third/util/option/struct.Type_search= Demonstrates converting between different types using `From` and creating a type from an iterator using `FromIterator`. These are fundamental for interoperability and collection handling. ```rust impl From for AVOptionType { fn from(value: Type) -> AVOptionType; } impl FromIterator for Type { fn from_iter>(iterator: T) -> Self; } ``` -------------------------------- ### Copy and Structural Equality Source: https://docs.rs/ffmpeg-the-third/latest/ffmpeg_the_third/util/option/struct.Type_search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E Documents the `Copy` trait for value copying and `StructuralPartialEq` for structural comparison. ```APIDOC ## Copy and Structural Equality ### `Copy` for `Type` Indicates that `Type` can be copied by simply copying its bits. ### `StructuralPartialEq` for `Type` Indicates that `Type` can be compared for structural equality. ``` -------------------------------- ### Basic Trait Implementations (Copy, Eq, Send, Sync, etc.) Source: https://docs.rs/ffmpeg-the-third/latest/ffmpeg_the_third/util/option/struct.Type_search= Lists fundamental trait implementations like Copy, Eq, and thread-safety traits. ```APIDOC ### impl Copy for Type ### Description Allows instances of the type to be copied implicitly. ### impl Eq for Type ### Description Guarantees that equality is reflexive, symmetric, and transitive. ### impl Freeze for Type ### Description Indicates that the type does not contain any non-`Sync` mutable data. ### impl RefUnwindSafe for Type ### Description Indicates that references to the type are unwind safe. ### impl Send for Type ### Description Indicates that the type can be safely transferred between threads. ### impl Sync for Type ### Description Indicates that the type can be safely shared between threads via references. ### impl Unpin for Type ### Description Indicates that the type does not need to be pinned to be moved. ### impl UnwindSafe for Type ### Description Indicates that the type is unwind safe. ``` -------------------------------- ### Comparison: Ord, PartialEq, PartialOrd Source: https://docs.rs/ffmpeg-the-third/latest/ffmpeg_the_third/util/option/struct.Type_search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E Provides comparison functionalities including ordering (`Ord`), equality (`PartialEq`), and partial ordering (`PartialOrd`). This allows for sorting, searching, and conditional logic based on 'Type' values. ```rust impl Ord for Type fn cmp(&self, other: &Type) -> Ordering fn max(self, other: Self) -> Self fn min(self, other: Self) -> Self fn clamp(self, min: Self, max: Self) -> Self impl PartialEq for Type fn eq(&self, other: &Type) -> bool fn ne(&self, other: &Rhs) -> bool impl PartialOrd for Type fn partial_cmp(&self, other: &Type) -> Option fn lt(&self, other: &Rhs) -> bool fn le(&self, other: &Rhs) -> bool fn gt(&self, other: &Rhs) -> bool fn ge(&self, other: &Rhs) -> bool ``` -------------------------------- ### Create New Rational Instance - Rust Source: https://docs.rs/ffmpeg-the-third/latest/ffmpeg_the_third/util/rational/struct.Rational_search=u32+-%3E+bool Provides a constructor function 'new' to create a 'Rational' instance. It takes numerator and denominator as i32 values and returns a new 'Rational' struct. This is the standard way to instantiate a Rational object. ```rust pub fn new(numerator: i32, denominator: i32) -> Self ``` -------------------------------- ### Formatting and Operator Implementations Source: https://docs.rs/ffmpeg-the-third/latest/ffmpeg_the_third/util/option/struct.Type_search= Covers implementations for formatting (hexadecimal, octal) and common operators like bitwise NOT and subtraction. ```APIDOC ## LowerHex for Type ### Description Allows formatting the type as a lowercase hexadecimal string. ### Method `fmt` ### Parameters - **f** (Formatter<'_>) - The formatter to use. ## Not for Type ### Description Implements the bitwise NOT operator (`!`). ### Method `not` ### Return Type - **Output** (Type) - The resulting type after applying the `!` operator. ### Description The bitwise negation (`!`) of the bits in a flags value, truncating the result. ## Octal for Type ### Description Allows formatting the type as an octal string. ### Method `fmt` ### Parameters - **f** (Formatter<'_>) - The formatter to use. ## Sub for Type ### Description Implements the subtraction operator (`-`), typically representing set difference for flags. ### Method `sub` ### Return Type - **Output** (Type) - The resulting type after applying the `-` operator. ### Description The intersection of a source flags value with the complement of a target flags value (`&!`). This method is not equivalent to `self & !other` when `other` has unknown bits set. `difference` won’t truncate `other`, but the `!` operator will. ## SubAssign for Type ### Description Implements the subtraction assignment operator (`-=`), modifying the value in place. ### Method `sub_assign` ### Parameters - **other** (Self) - The value to subtract. ### Description The intersection of a source flags value with the complement of a target flags value (`&!`). This method is not equivalent to `self & !other` when `other` has unknown bits set. `difference` won’t truncate `other`, but the `!` operator will. ## UpperHex for Type ### Description Allows formatting the type as an uppercase hexadecimal string. ### Method `fmt` ### Parameters - **f** (Formatter<'_>) - The formatter to use. ``` -------------------------------- ### Equality and Structural Equality Source: https://docs.rs/ffmpeg-the-third/latest/ffmpeg_the_third/util/option/struct.Type_search= Documentation for equality and structural equality checks. ```APIDOC ## PartialEq for Type ### Description Allows checking for equality between instances of the type. ### Method `eq` ### Parameters - **other** (Type) - The other value to compare against. ### Return Type - **bool** - `true` if the values are equal, `false` otherwise. ### Method `ne` ### Parameters - **other** (Rhs) - The other value to compare against. ### Return Type - **bool** - `true` if the values are not equal, `false` otherwise. ## StructuralPartialEq for Type ### Description Enables structural equality comparisons, which may differ from standard equality in certain cases. ``` -------------------------------- ### Type Conversion with `From` and `Into` Source: https://docs.rs/ffmpeg-the-third/latest/ffmpeg_the_third/util/option/struct.Type_search= This section details the conversion capabilities between different FFmpeg types using the `From` and `Into` traits. ```APIDOC ## From for Type ### Description Converts to `AVOptionType` from the input type. ### Method `from` ### Parameters - **value** (Type) - Description: The input value to convert. ## From for AVOptionType ### Description Converts to the specified `Type` from `AVOptionType`. ### Method `from` ### Parameters - **value** (AVOptionType) - Description: The input `AVOptionType` value to convert. ## FromIterator for Type ### Description Creates a new instance of `Type` by consuming an iterator. ### Method `from_iter` ### Parameters - **iterator** (T: IntoIterator) - Description: An iterator yielding items of the same type to construct the new instance. ### Example ```rust let my_type_instance: Type = iterator.collect(); ``` ``` -------------------------------- ### Auto Trait Implementations Source: https://docs.rs/ffmpeg-the-third/latest/ffmpeg_the_third/util/option/struct.Type_search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E Lists the automatically derived trait implementations for `Type`, including `Freeze`, `RefUnwindSafe`, `Send`, `Sync`, `Unpin`, and `UnwindSafe`. ```APIDOC ## Auto Trait Implementations ### `Freeze` for `Type` Indicates that `Type` does not contain interior mutability. ### `RefUnwindSafe` for `Type` Indicates that references to `Type` are safe to use across unwinding. ### `Send` for `Type` Indicates that `Type` can be safely transferred between threads. ### `Sync` for `Type` Indicates that references to `Type` can be safely shared between threads. ### `Unpin` for `Type` Indicates that `Type` does not need to be pinned to be moved. ### `UnwindSafe` for `Type` Indicates that `Type` is safe to use across unwinding. ``` -------------------------------- ### Iterator Implementations Source: https://docs.rs/ffmpeg-the-third/latest/ffmpeg_the_third/util/option/struct.Type_search= Details on how FFmpeg types can be iterated over. ```APIDOC ## IntoIterator for Type ### Description Provides the ability to iterate over the elements of a type. ### Associated Types - **Item** (Type) - The type of the elements being iterated over. - **IntoIter** (Iter) - The specific type of the iterator. ### Method `into_iter` ### Description Creates an iterator from a value. ### Example ```rust let my_type_instance: Type = /* ... */; for item in my_type_instance.into_iter() { // process item } ``` ``` -------------------------------- ### Rust: Implement From Trait for Type Conversion Source: https://docs.rs/ffmpeg-the-third/latest/ffmpeg_the_third/util/rational/struct.Rational_search=u32+-%3E+bool Demonstrates how to implement the `From` trait for a type `U`. This allows for direct conversion from type `T` to type `U` using `U::from(value)`. ```rust struct MyStruct; impl From for MyStruct { fn from(t: i32) -> MyStruct { // Conversion logic here MyStruct } } ``` -------------------------------- ### Type Conversions: From and IntoIterator Source: https://docs.rs/ffmpeg-the-third/latest/ffmpeg_the_third/util/option/struct.Type_search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E Demonstrates converting between types using the `From` trait and creating iterators using `FromIterator` and `IntoIterator`. This is crucial for data transformation and collection processing. ```rust impl From for AVOptionType fn from(value: Type) -> AVOptionType impl FromIterator for Type fn from_iter>(iterator: T) -> Self impl IntoIterator for Type type Item = Type type IntoIter = Iter fn into_iter(self) -> Self::IntoIter ``` -------------------------------- ### Rust Ordering and Comparison Traits (Ord, max, min, clamp) Source: https://docs.rs/ffmpeg-the-third/latest/ffmpeg_the_third/util/option/struct.Type_search= Implements total ordering for `Type`, allowing comparison using `cmp`, and provides methods for finding the maximum (`max`), minimum (`min`), and clamping (`clamp`) values within a range. ```rust impl Ord for Type { fn cmp(&self, other: &Type) -> Ordering; fn max(self, other: Self) -> Self where Self: Sized; fn min(self, other: Self) -> Self where Self: Sized; fn clamp(self, min: Self, max: Self) -> Self where Self: Sized; } ``` -------------------------------- ### Rust Formatting Traits (LowerHex, Octal, UpperHex) Source: https://docs.rs/ffmpeg-the-third/latest/ffmpeg_the_third/util/option/struct.Type_search= Shows how to format a `Type` into different number bases (lowercase hex, octal, uppercase hex) using the `fmt` method within their respective traits. ```rust impl LowerHex for Type { fn fmt(&self, f: &mut Formatter<'_>) -> Result; } impl Octal for Type { fn fmt(&self, f: &mut Formatter<'_>) -> Result; } impl UpperHex for Type { fn fmt(&self, f: &mut Formatter<'_>) -> Result; } ``` -------------------------------- ### Formatting and Bitwise Operations Source: https://docs.rs/ffmpeg-the-third/latest/ffmpeg_the_third/util/option/struct.Type_search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E Details the implementations for formatting numbers in lower hex, octal, and upper hex, as well as bitwise NOT and subtraction operations. ```APIDOC ## Formatting and Bitwise Operations ### `LowerHex` for `Type` Formats the value using the given formatter in lower hexadecimal. ### `Not` for `Type` - **Output**: `Type` The bitwise negation (`!`) of the bits in a flags value, truncating the result. ### `Octal` for `Type` Formats the value using the given formatter in octal. ### `Sub` for `Type` - **Output**: `Type` The intersection of a source flags value with the complement of a target flags value (`&!`). This method is not equivalent to `self & !other` when `other` has unknown bits set. ### `SubAssign` for `Type` The intersection of a source flags value with the complement of a target flags value (`&!`). This method is not equivalent to `self & !other` when `other` has unknown bits set. ### `UpperHex` for `Type` Formats the value using the given formatter in upper hexadecimal. ``` -------------------------------- ### Rust: Implement TryInto Trait for Fallible Conversion Source: https://docs.rs/ffmpeg-the-third/latest/ffmpeg_the_third/util/rational/struct.Rational_search=u32+-%3E+bool Shows how to implement `TryInto` for a type `T`, which requires `U: TryFrom`. This allows attempting conversion from `T` to `U` using `value.try_into()`. ```rust struct MyData; impl TryFrom for i32 { type Error = &'static str; fn try_from(value: MyData) -> Result { // Conversion logic that might fail Err("Conversion failed") } } // Usage: // let data = MyData; // let result: Result = data.try_into(); ``` -------------------------------- ### Rust: Implement ToString Trait for String Conversion Source: https://docs.rs/ffmpeg-the-third/latest/ffmpeg_the_third/util/rational/struct.Rational_search=u32+-%3E+bool Demonstrates implementing the `ToString` trait for a type `T` where `T` also implements `Display`. This allows conversion to a `String` using the `to_string()` method. ```rust use std::fmt::Display; struct MyNumber(i32); impl Display for MyNumber { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { write!(f, "{}", self.0) } } // Usage: // let num = MyNumber(42); // let s = num.to_string(); ``` -------------------------------- ### Conversion from AVOptionType (Rust) Source: https://docs.rs/ffmpeg-the-third/latest/ffmpeg_the_third/util/option/struct.Type_search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E Defines how to create a Type instance from an AVOptionType. This conversion likely maps specific AVOptionType values to the corresponding flags in the Type enum. ```Rust impl From for Type ``` -------------------------------- ### Rational Debug Formatting - Rust Source: https://docs.rs/ffmpeg-the-third/latest/ffmpeg_the_third/util/rational/struct.Rational_search=u32+-%3E+bool Implements the 'Debug' trait for 'Rational', enabling formatted output for debugging purposes. The 'fmt' method allows the struct to be printed in a developer-friendly representation. ```rust fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error> ``` -------------------------------- ### PublicFlags Implementation Source: https://docs.rs/ffmpeg-the-third/latest/ffmpeg_the_third/util/option/struct.Type_search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E Details the `PublicFlags` trait implementation for `Type`, specifying primitive and internal types. ```APIDOC ## PublicFlags Implementation ### `PublicFlags` for `Type` - **Primitive**: `u32` (The type of the underlying storage.) - **Internal**: `InternalBitFlags` (The type of the internal field on the generated flags type.) ``` -------------------------------- ### Rational Equality Comparison - Rust Source: https://docs.rs/ffmpeg-the-third/latest/ffmpeg_the_third/util/rational/struct.Rational_search=u32+-%3E+bool Implements the 'PartialEq' trait for 'Rational', enabling equality checks using the '==' and '!=' operators. The 'eq' method compares two 'Rational' numbers for equality, returning a boolean. 'ne' handles inequality. ```rust fn eq(&self, other: &Rational) -> bool fn ne(&self, other: &Rhs) -> bool ``` -------------------------------- ### Rational Ordering Comparison - Rust Source: https://docs.rs/ffmpeg-the-third/latest/ffmpeg_the_third/util/rational/struct.Rational_search=u32+-%3E+bool Implements the 'PartialOrd' trait for 'Rational', enabling ordered comparisons using '<', '<=', '>', and '>=' operators. The 'partial_cmp' method returns an 'Option' for comparing 'Rational' values. Helper methods like 'lt', 'le', 'gt', and 'ge' are also provided. ```rust fn partial_cmp(&self, other: &Self) -> Option fn lt(&self, other: &Rhs) -> bool fn le(&self, other: &Rhs) -> bool fn gt(&self, other: &Rhs) -> bool fn ge(&self, other: &Rhs) -> bool ``` -------------------------------- ### Rust: Implement TryFrom Trait for Fallible Conversion Source: https://docs.rs/ffmpeg-the-third/latest/ffmpeg_the_third/util/rational/struct.Rational_search=u32+-%3E+bool Illustrates the `TryFrom` trait for attempting conversions that might fail. It returns a `Result` with the converted type or an `Error`. ```rust use std::convert::Infallible; struct MyIntWrapper(i32); impl TryFrom for MyIntWrapper { type Error = Infallible; fn try_from(value: i32) -> Result { Ok(MyIntWrapper(value)) } } ``` -------------------------------- ### Convert Tuple to Rational - Rust Source: https://docs.rs/ffmpeg-the-third/latest/ffmpeg_the_third/util/rational/struct.Rational_search=u32+-%3E+bool Implements the 'From<(i32, i32)>' trait for 'Rational', allowing conversion from a tuple of two i32 integers (numerator, denominator) into a 'Rational' object. This simplifies initialization from common tuple representations. ```rust fn from((num, den): (i32, i32)) -> Rational ``` -------------------------------- ### Rational Division - Rust Source: https://docs.rs/ffmpeg-the-third/latest/ffmpeg_the_third/util/rational/struct.Rational_search=u32+-%3E+bool Implements the 'Div' trait for 'Rational', enabling division using the '/' operator. The 'div' function takes two 'Rational' numbers and returns their quotient as a new 'Rational' instance. The 'Output' type is 'Rational'. ```rust type Output = Rational fn div(self, other: Rational) -> Rational ``` -------------------------------- ### Rust Partial Ordering Traits (PartialOrd, partial_cmp, lt, le, gt, ge) Source: https://docs.rs/ffmpeg-the-third/latest/ffmpeg_the_third/util/option/struct.Type_search= Implements partial ordering for `Type`, enabling comparisons like less than (`<`), less than or equal to (`<=`), greater than (`>`), and greater than or equal to (`>=`), as well as a `partial_cmp` method. ```rust impl PartialOrd for Type { fn partial_cmp(&self, other: &Type) -> Option; fn lt(&self, other: &Rhs) -> bool; fn le(&self, other: &Rhs) -> bool; fn gt(&self, other: &Rhs) -> bool; fn ge(&self, other: &Rhs) -> bool; } ``` -------------------------------- ### Formatting: LowerHex, Octal, UpperHex Source: https://docs.rs/ffmpeg-the-third/latest/ffmpeg_the_third/util/option/struct.Type_search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E Enables formatting of the 'Type' in different number bases (hexadecimal and octal) using the `LowerHex`, `Octal`, and `UpperHex` traits. This is useful for debugging and representation. ```rust impl LowerHex for Type fn fmt(&self, f: &mut Formatter<'_>) -> Result impl Octal for Type fn fmt(&self, f: &mut Formatter<'_>) -> Result impl UpperHex for Type fn fmt(&self, f: &mut Formatter<'_>) -> Result ``` -------------------------------- ### Access Rational Numerator and Denominator - Rust Source: https://docs.rs/ffmpeg-the-third/latest/ffmpeg_the_third/util/rational/struct.Rational_search=u32+-%3E+bool Offers getter methods 'numerator' and 'denominator' to retrieve the respective parts of a 'Rational' number. These methods return the i32 values of the numerator and denominator, respectively, allowing for read-only access to the struct's components. ```rust pub fn numerator(&self) -> i32 ``` ```rust pub fn denominator(&self) -> i32 ``` -------------------------------- ### ffmpeg_the_third Type Constants for Data Types Source: https://docs.rs/ffmpeg-the-third/latest/ffmpeg_the_third/util/option/struct.Type_search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E Provides a list of public static constants within the 'Type' enum, representing common FFmpeg data types such as INT, STRING, RATIONAL, and more. These constants are used to specify the expected format of FFmpeg options. ```rust pub const FLAGS: Self pub const INT: Self pub const INT64: Self pub const DOUBLE: Self pub const FLOAT: Self pub const STRING: Self pub const RATIONAL: Self pub const BINARY: Self pub const DICTIONARY: Self pub const CONSTANT: Self pub const IMAGE_SIZE: Self pub const PIXEL_FORMAT: Self pub const SAMPLE_FORMAT: Self pub const VIDEO_RATE: Self pub const DURATION: Self pub const COLOR: Self pub const CHANNEL_LAYOUT: Self pub const CHLAYOUT: Self pub const C_ULONG: Self pub const BOOL: Self ``` -------------------------------- ### Rational Addition - Rust Source: https://docs.rs/ffmpeg-the-third/latest/ffmpeg_the_third/util/rational/struct.Rational_search=u32+-%3E+bool Implements the 'Add' trait for the 'Rational' struct, enabling addition using the '+' operator. The 'add' function takes two 'Rational' numbers and returns their sum as a new 'Rational' instance. The 'Output' type is also defined as 'Rational'. ```rust type Output = Rational fn add(self, other: Rational) -> Rational ``` -------------------------------- ### Rust: Implement Into Trait for Type Conversion Source: https://docs.rs/ffmpeg-the-third/latest/ffmpeg_the_third/util/rational/struct.Rational_search=u32+-%3E+bool Shows how to implement the `Into` trait for a type `T`, which requires `U: From`. This enables conversion from `T` to `U` using `value.into()`. ```rust struct MyOtherStruct; impl From for String { fn from(t: MyOtherStruct) -> String { String::from("converted") } } // Usage: // let instance = MyOtherStruct; // let s: String = instance.into(); ``` -------------------------------- ### Convert Rational to f64 - Rust Source: https://docs.rs/ffmpeg-the-third/latest/ffmpeg_the_third/util/rational/struct.Rational_search=u32+-%3E+bool Implements the 'From' trait for 'f64', enabling conversion of a 'Rational' number to a floating-point 'f64' value. This allows for direct use of rational numbers in floating-point calculations. ```rust fn from(value: Rational) -> f64 ``` -------------------------------- ### Convert f64 to Rational - Rust Source: https://docs.rs/ffmpeg-the-third/latest/ffmpeg_the_third/util/rational/struct.Rational_search=u32+-%3E+bool Implements the 'From' trait for 'Rational', allowing conversion from a floating-point 'f64' value to a 'Rational' number. This function likely approximates the floating-point value as a fraction. ```rust fn from(value: f64) -> Rational ``` -------------------------------- ### Reduce Rational with Limit - Rust Source: https://docs.rs/ffmpeg-the-third/latest/ffmpeg_the_third/util/rational/struct.Rational_search=u32+-%3E+bool Provides a 'reduce_with_limit' function for 'Rational' numbers. This method attempts to reduce the fraction while respecting a maximum value for the denominator. It returns a Result, indicating success with a reduced Rational or failure with the original Rational if the limit is exceeded. ```rust pub fn reduce_with_limit(&self, max: i32) -> Result ``` -------------------------------- ### Convert AVRational to Rational - Rust Source: https://docs.rs/ffmpeg-the-third/latest/ffmpeg_the_third/util/rational/struct.Rational_search=u32+-%3E+bool Implements the 'From' trait for 'Rational', enabling conversion from an 'AVRational' type (likely from the FFmpeg library) to the crate's 'Rational' struct. This facilitates interoperability with FFmpeg components. ```rust fn from(value: AVRational) -> Rational ``` -------------------------------- ### Rational Cloning - Rust Source: https://docs.rs/ffmpeg-the-third/latest/ffmpeg_the_third/util/rational/struct.Rational_search=u32+-%3E+bool Implements the 'Clone' trait for the 'Rational' struct, allowing instances to be duplicated. The 'clone' method creates a deep copy of the 'Rational' value. 'clone_from' is also provided for efficient in-place copying. ```rust fn clone(&self) -> Rational fn clone_from(&mut self, source: &Self) ``` -------------------------------- ### Core Flags Operations (Rust) Source: https://docs.rs/ffmpeg-the-third/latest/ffmpeg_the_third/util/option/struct.Type_search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E Defines fundamental operations for a flags type, including accessing underlying bits, creating empty or all-set flags, converting from bits, and checking for unknown bits. ```Rust impl Flags for Type { const FLAGS: &'static [Flag]; type Bits = u32; fn bits(&self) -> c_uint; fn from_bits_retain(bits: c_uint) -> Type; fn empty() -> Self; fn all() -> Self; fn contains_unknown_bits(&self) -> bool; fn from_bits(bits: Self::Bits) -> Option; fn from_bits_truncate(bits: Self::Bits) -> Self; fn from_name(name: &str) -> Option; fn iter(&self) -> Iter; fn iter_names(&self) -> IterNames; fn is_empty(&self) -> bool; fn is_all(&self) -> bool; } ``` -------------------------------- ### ffmpeg_the_third Type Flag Manipulation Functions Source: https://docs.rs/ffmpeg-the-third/latest/ffmpeg_the_third/util/option/struct.Type_search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E Details various utility functions for manipulating flags represented by the 'Type' struct. This includes creating empty or all-set flags, converting from and to raw bit values, checking for intersections, and performing set operations like insert, remove, and toggle. ```rust pub const fn empty() -> Self pub const fn all() -> Self pub const fn bits(&self) -> c_uint pub const fn from_bits(bits: c_uint) -> Option pub const fn from_bits_truncate(bits: c_uint) -> Self pub const fn from_bits_retain(bits: c_uint) -> Self pub fn from_name(name: &str) -> Option pub const fn is_empty(&self) -> bool pub const fn is_all(&self) -> bool pub const fn intersects(&self, other: Self) -> bool pub const fn contains(&self, other: Self) -> bool pub fn insert(&mut self, other: Self) pub fn remove(&mut self, other: Self) pub fn toggle(&mut self, other: Self) pub fn set(&mut self, other: Self, value: bool) ``` -------------------------------- ### Set-Theoretic Flags Operations (Rust) Source: https://docs.rs/ffmpeg-the-third/latest/ffmpeg_the_third/util/option/struct.Type_search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E Implements set-theoretic operations on flag values, including union (OR), intersection (AND), difference, and symmetric difference (XOR). These methods return new flag values representing the result. ```Rust impl Flags for Type { // ... other methods fn intersection(self, other: Self) -> Self; fn union(self, other: Self) -> Self; fn difference(self, other: Self) -> Self; fn symmetric_difference(self, other: Self) -> Self; fn complement(self) -> Self; } ``` -------------------------------- ### Reduce Rational Number - Rust Source: https://docs.rs/ffmpeg-the-third/latest/ffmpeg_the_third/util/rational/struct.Rational_search=u32+-%3E+bool Implements a 'reduce' function for the 'Rational' struct. This method simplifies the fraction to its lowest terms. It returns a new 'Rational' instance representing the reduced fraction. ```rust pub fn reduce(&self) -> Rational ``` -------------------------------- ### Public Flags Implementation Source: https://docs.rs/ffmpeg-the-third/latest/ffmpeg_the_third/util/option/struct.Type_search= Details on the `PublicFlags` trait implementation for types representing flags. ```APIDOC ## PublicFlags for Type ### Description Provides access to the underlying primitive and internal representation for flag types. ### Associated Types - **Primitive** (u32) - The type of the underlying storage for the flags. - **Internal** (InternalBitFlags) - The type of the internal field on the generated flags type. ``` -------------------------------- ### Bitwise OR for Flags (Rust) Source: https://docs.rs/ffmpeg-the-third/latest/ffmpeg_the_third/util/option/struct.Type_search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E Calculates the bitwise OR of two flag values, returning a new flag value with bits set if they are set in either operand. The `Output` type is also defined for this operation. ```Rust impl BitOr for Type { type Output = Type; fn bitor(self, other: Type) -> Self; } ``` -------------------------------- ### ffmpeg_the_third::util::option::Type Constants Source: https://docs.rs/ffmpeg-the-third/latest/ffmpeg_the_third/util/option/struct.Type_search= Defines various constants representing different data types for ffmpeg options. These include numerical types (INT, INT64, DOUBLE, FLOAT), string types (STRING, BINARY), complex types (DICTIONARY, IMAGE_SIZE, PIXEL_FORMAT), and more specific ffmpeg-related types (VIDEO_RATE, CHANNEL_LAYOUT). ```Rust pub struct Type(/* private fields */); impl Type { pub const FLAGS: Self) pub const INT: Self) pub const INT64: Self) pub const DOUBLE: Self) pub const FLOAT: Self) pub const STRING: Self) pub const RATIONAL: Self) pub const BINARY: Self pub const DICTIONARY: Self) pub const CONSTANT: Self) pub const IMAGE_SIZE: Self) pub const PIXEL_FORMAT: Self) pub const SAMPLE_FORMAT: Self) pub const VIDEO_RATE: Self) pub const DURATION: Self) pub const COLOR: Self) pub const CHANNEL_LAYOUT: Self) pub const CHLAYOUT: Self) pub const C_ULONG: Self) pub const BOOL: Self) } ``` -------------------------------- ### Set-Based Flags Operations (Rust) Source: https://docs.rs/ffmpeg-the-third/latest/ffmpeg_the_third/util/option/struct.Type_search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E Provides methods for comparing and manipulating flag values as sets. Includes checks for intersection, containment, and modifying flags by inserting, removing, or toggling. ```Rust impl Flags for Type { // ... other methods fn intersects(&self, other: Self) -> bool; fn contains(&self, other: Self) -> bool; fn truncate(&mut self); fn insert(&mut self, other: Self); fn remove(&mut self, other: Self); fn toggle(&mut self, other: Self); fn set(&mut self, other: Self, value: bool); fn clear(&mut self); } ``` -------------------------------- ### Bitwise Operations: Not and Subtraction Source: https://docs.rs/ffmpeg-the-third/latest/ffmpeg_the_third/util/option/struct.Type_search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E Implements bitwise negation using the `Not` trait and set difference using the `Sub` trait. These are essential for manipulating flag-like data structures efficiently. ```rust impl Not for Type fn not(self) -> Self type Output = Type impl Sub for Type fn sub(self, other: Self) -> Self type Output = Type ``` -------------------------------- ### ffmpeg_the_third::util::option::Type Iteration and Bitwise Operations Source: https://docs.rs/ffmpeg-the-third/latest/ffmpeg_the_third/util/option/struct.Type_search= Enables iteration over the flags within a `Type` instance using `iter` and `iter_names`. Also includes implementations for standard bitwise operators like `&` (BitAnd) and `&=` (BitAndAssign), allowing for direct manipulation of flags using familiar syntax. ```Rust impl Type { pub const fn iter(&self) -> Iter pub const fn iter_names(&self) -> IterNames } impl Binary for Type { fn fmt(&self, f: &mut Formatter<'_>) -> Result } impl BitAnd for Type { fn bitand(self, other: Self) -> Self type Output = Type } impl BitAndAssign for Type { // Method definition would be here if specified } ``` -------------------------------- ### Convert Rational to AVRational - Rust Source: https://docs.rs/ffmpeg-the-third/latest/ffmpeg_the_third/util/rational/struct.Rational_search=u32+-%3E+bool Implements the 'From' trait for 'AVRational', allowing conversion from the crate's 'Rational' struct to an 'AVRational' type. This is useful for passing 'Rational' data to FFmpeg functions. ```rust fn from(value: Rational) -> AVRational ``` -------------------------------- ### Rational Multiplication - Rust Source: https://docs.rs/ffmpeg-the-third/latest/ffmpeg_the_third/util/rational/struct.Rational_search=u32+-%3E+bool Implements the 'Mul' trait for 'Rational', enabling multiplication using the '*' operator. The 'mul' function takes two 'Rational' numbers and returns their product as a new 'Rational' instance. The 'Output' type is 'Rational'. ```rust type Output = Rational fn mul(self, other: Rational) -> Rational ``` -------------------------------- ### Rational Subtraction - Rust Source: https://docs.rs/ffmpeg-the-third/latest/ffmpeg_the_third/util/rational/struct.Rational_search=u32+-%3E+bool Implements the 'Sub' trait for 'Rational', enabling subtraction using the '-' operator. The 'sub' function takes two 'Rational' numbers and returns their difference as a new 'Rational' instance. The 'Output' type is 'Rational'. ```rust type Output = Rational fn sub(self, other: Rational) -> Rational ``` -------------------------------- ### ffmpeg_the_third::util::option::Type Flag Manipulation Methods Source: https://docs.rs/ffmpeg-the-third/latest/ffmpeg_the_third/util/option/struct.Type_search= Provides methods for managing flag values represented by the `Type` struct. This includes creating empty or all-set flags, converting between raw bit values and `Type` instances (with or without truncation), checking for empty or all-set states, and performing set operations like intersection, union, difference, and symmetric difference. ```Rust impl Type { pub const fn empty() -> Self pub const fn all() -> Self pub const fn bits(&self) -> c_uint pub const fn from_bits(bits: c_uint) -> Option pub const fn from_bits_truncate(bits: c_uint) -> Self pub const fn from_bits_retain(bits: c_uint) -> Self pub fn from_name(name: &str) -> Option pub const fn is_empty(&self) -> bool pub const fn is_all(&self) -> bool pub const fn intersects(&self, other: Self) -> bool pub const fn contains(&self, other: Self) -> bool pub fn insert(&mut self, other: Self) pub fn remove(&mut self, other: Self) pub fn toggle(&mut self, other: Self) pub fn set(&mut self, other: Self, value: bool) pub const fn intersection(self, other: Self) -> Self pub const fn union(self, other: Self) -> Self pub const fn difference(self, other: Self) -> Self pub const fn symmetric_difference(self, other: Self) -> Self pub const fn complement(self) -> Self } ``` -------------------------------- ### Rust: Implement ToOwned Trait for Data Ownership Source: https://docs.rs/ffmpeg-the-third/latest/ffmpeg_the_third/util/rational/struct.Rational_search=u32+-%3E+bool Explains the `ToOwned` trait, which provides methods to create owned data from borrowed data, typically through cloning. It includes `to_owned()` and `clone_into()`. ```rust impl ToOwned for str { type Owned = String; fn to_owned(&self) -> String { self.to_string() } fn clone_into(&self, target: &mut String) { target.clear(); target.push_str(self); } } ``` -------------------------------- ### Bitwise AND Assignment for Flags (Rust) Source: https://docs.rs/ffmpeg-the-third/latest/ffmpeg_the_third/util/option/struct.Type_search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E Performs a bitwise AND operation between two flag values and assigns the result to the first operand. This is useful for masking or checking for common set bits. ```Rust impl BitAndAssign for Type { fn bitand_assign(&mut self, other: Self); } ``` -------------------------------- ### ffmpeg_the_third Type Bitwise Operations (BitAnd) Source: https://docs.rs/ffmpeg-the-third/latest/ffmpeg_the_third/util/option/struct.Type_search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E Implements the BitAnd trait for the 'Type' struct, enabling bitwise AND operations. This is used for combining flags or checking for common bits between two 'Type' values. The output is also of type 'Type'. ```rust fn bitand(self, other: Self) -> Self type Output = Type ``` -------------------------------- ### Mutable Operations: SubAssign Source: https://docs.rs/ffmpeg-the-third/latest/ffmpeg_the_third/util/option/struct.Type_search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E Implements in-place subtraction for flag-like types using `SubAssign`. This allows for efficient modification of flags without creating new values. ```rust impl SubAssign for Type fn sub_assign(&mut self, other: Self) ``` -------------------------------- ### Type Aliases and PublicFlags Trait Source: https://docs.rs/ffmpeg-the-third/latest/ffmpeg_the_third/util/option/struct.Type_search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E Defines type aliases for primitive and internal storage types within the `PublicFlags` trait. This clarifies the underlying representation of flag types. ```rust impl PublicFlags for Type type Primitive = u32 type Internal = InternalBitFlags ``` -------------------------------- ### Bitwise XOR for Flags (Rust) Source: https://docs.rs/ffmpeg-the-third/latest/ffmpeg_the_third/util/option/struct.Type_search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E Computes the bitwise exclusive-OR of two flag values, returning a new flag value where bits are set if they are set in exactly one of the operands. The `Output` type is also defined. ```Rust impl BitXor for Type { type Output = Type; fn bitxor(self, other: Self) -> Self; } ``` -------------------------------- ### Creating Flags from Raw Bits (Retain Unknown) Source: https://docs.rs/ffmpeg-the-third/latest/ffmpeg_the_third/util/option/struct.Type_search= Creates a flags value directly from a raw bits representation, preserving any unknown bits. Use with caution, as unknown bits may cause unexpected behavior. ```rust fn from_bits_retain(bits: c_uint) -> Type ``` -------------------------------- ### Rational Send and Sync Traits - Rust Source: https://docs.rs/ffmpeg-the-third/latest/ffmpeg_the_third/util/rational/struct.Rational_search=u32+-%3E+bool Declares 'Send' and 'Sync' trait implementations for 'Rational'. These auto-traits indicate that 'Rational' values can be safely transferred between threads ('Send') and accessed concurrently from multiple threads ('Sync'), making them thread-safe. ```rust impl Send for Rational impl Sync for Rational ``` -------------------------------- ### ffmpeg_the_third Type Struct Definition Source: https://docs.rs/ffmpeg-the-third/latest/ffmpeg_the_third/util/option/struct.Type_search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E Defines the 'Type' struct, which is likely an internal representation for FFmpeg options. It contains private fields and is used to represent various data types and flags. ```rust pub struct Type(/* private fields */); ``` -------------------------------- ### Invert Rational Number - Rust Source: https://docs.rs/ffmpeg-the-third/latest/ffmpeg_the_third/util/rational/struct.Rational_search=u32+-%3E+bool Implements an 'invert' function for the 'Rational' struct. This method returns a new 'Rational' instance that is the multiplicative inverse (reciprocal) of the original. It effectively swaps the numerator and denominator. ```rust pub fn invert(&self) -> Rational ``` -------------------------------- ### Rational Copy Implementation - Rust Source: https://docs.rs/ffmpeg-the-third/latest/ffmpeg_the_third/util/rational/struct.Rational_search=u32+-%3E+bool Declares the 'Copy' trait implementation for 'Rational'. This indicates that 'Rational' values can be copied implicitly (like primitive types) rather than moved, which is efficient for small, simple data structures. ```rust impl Copy for Rational ``` -------------------------------- ### Convert Rational to u32 - Rust Source: https://docs.rs/ffmpeg-the-third/latest/ffmpeg_the_third/util/rational/struct.Rational_search=u32+-%3E+bool Implements the 'From' trait for 'u32'. This conversion likely involves truncating or rounding the rational number to fit into an unsigned 32-bit integer. The exact behavior depends on the implementation's logic. ```rust fn from(value: Rational) -> u32 ``` -------------------------------- ### Default Value for Flags (Rust) Source: https://docs.rs/ffmpeg-the-third/latest/ffmpeg_the_third/util/option/struct.Type_search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E Provides a default value for the flag type, typically representing an empty set of flags (all bits unset). This is useful for initializing flag variables. ```Rust impl Default for Type { fn default() -> Self; } ``` -------------------------------- ### Bitwise XOR Assignment for Flags (Rust) Source: https://docs.rs/ffmpeg-the-third/latest/ffmpeg_the_third/util/option/struct.Type_search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E Performs a bitwise XOR operation between two flag values and assigns the result to the first operand. This is used to toggle the presence of specific flags. ```Rust impl BitXorAssign for Type { fn bitxor_assign(&mut self, other: Self); } ``` -------------------------------- ### Bitwise XOR (^) for Flags Source: https://docs.rs/ffmpeg-the-third/latest/ffmpeg_the_third/util/option/struct.Type_search= Calculates the bitwise XOR of two flag values, returning a new flag value where bits are set if they are set in exactly one of the operands. This is useful for toggling flags. ```rust fn bitxor(self, other: Self) -> Self ``` -------------------------------- ### Rational Eq Implementation - Rust Source: https://docs.rs/ffmpeg-the-third/latest/ffmpeg_the_third/util/rational/struct.Rational_search=u32+-%3E+bool Declares the 'Eq' trait implementation for 'Rational'. This signifies that the equality relation is reflexive, symmetric, and transitive for 'Rational' values, which is a requirement for types used in collections like 'HashMap' keys. ```rust impl Eq for Rational ``` -------------------------------- ### Bitwise OR Assignment for Flags (Rust) Source: https://docs.rs/ffmpeg-the-third/latest/ffmpeg_the_third/util/option/struct.Type_search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E Performs a bitwise OR operation between two flag values and assigns the result to the first operand. This is used to add flags from one value to another. ```Rust impl BitOrAssign for Type { fn bitor_assign(&mut self, other: Self); } ``` -------------------------------- ### Bitwise OR (|) for Flags Source: https://docs.rs/ffmpeg-the-third/latest/ffmpeg_the_third/util/option/struct.Type_search= Calculates the bitwise OR of two flag values, returning a new flag value with bits set if they are set in either operand. This is commonly used to combine flags. ```rust fn bitor(self, other: Type) -> Self ``` -------------------------------- ### Extending Flags with Iterators (Rust) Source: https://docs.rs/ffmpeg-the-third/latest/ffmpeg_the_third/util/option/struct.Type_search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E Allows a flag value to be extended by iterating over other flag values, combining them using a bitwise OR operation. It supports extending with single items or collections. ```Rust impl Extend for Type { fn extend>(&mut self, iterator: T); fn extend_one(&mut self, item: A); fn extend_reserve(&mut self, additional: usize); } ```