### XChaCha20Poly1305 Encryption and Decryption Example Source: https://docs.rs/chacha20poly1305/latest/src/chacha20poly1305/lib.rs.html Demonstrates how to generate a key and nonce, encrypt a message, and then decrypt it using XChaCha20Poly1305. Requires the 'getrandom' and 'std' features. ```rust #![cfg_attr(all(feature = "getrandom", feature = "std"), doc = "```")] #![cfg_attr(not(all(feature = "getrandom", feature = "std")), doc = "```ignore")] # fn main() -> Result<(), Box> { use chacha20poly1305::{ aead::{Aead, AeadCore, KeyInit, OsRng}, XChaCha20Poly1305, XNonce }; let key = XChaCha20Poly1305::generate_key(&mut OsRng); let cipher = XChaCha20Poly1305::new(&key); let nonce = XChaCha20Poly1305::generate_nonce(&mut OsRng); // 192-bits; unique per message let ciphertext = cipher.encrypt(&nonce, b"plaintext message".as_ref())?; let plaintext = cipher.decrypt(&nonce, ciphertext.as_ref())?; assert_eq!(&plaintext, b"plaintext message"); # Ok(()) # } ``` ``` -------------------------------- ### Get Bit Source: https://docs.rs/chacha20poly1305/latest/chacha20poly1305/consts/type.U686.html Retrieves specific bits from a UInt value. ```APIDOC ### impl GetBit> for UInt #### type Output = as Sub>::Output>>::Output ### impl GetBit for UInt #### type Output = Bn ``` -------------------------------- ### impl KeyInit for Poly1305 Source: https://docs.rs/chacha20poly1305/latest/chacha20poly1305/trait.KeyInit.html Implementation of the KeyInit trait for the Poly1305 type, providing a specific method for initializing Poly1305 with a key. ```APIDOC ### impl KeyInit for Poly1305 #### fn new(key: &GenericArray::KeySize>) -> Poly1305 ### Description Initialize Poly1305 with the given key. ### Method Associated Function ### Parameters #### Path Parameters - **key** (&GenericArray::KeySize>) - Required - The key to initialize Poly1305 with. ``` -------------------------------- ### Get Bit Operation Source: https://docs.rs/chacha20poly1305/latest/chacha20poly1305/consts/type.U10000000000000.html Retrieves a specific bit from a `UInt` value. ```APIDOC ## Get Bit Operation for `UInt` ### Description Retrieves the value of a specific bit within a `UInt` number. #### Getting a bit from `UInt` - **Associated Type `Output`**: ` as Sub>::Output>>::Output` - **Description**: Retrieves a bit from a `UInt` where the bit position is specified by another `UInt`. #### Getting a bit from `UInt` with `UTerm` - **Associated Type `Output`**: `Bn` - **Description**: Retrieves the bit at the `UTerm` position (which is the least significant bit) from a `UInt`. ``` -------------------------------- ### Ordering Implementation Source: https://docs.rs/chacha20poly1305/latest/chacha20poly1305/consts/type.U262143.html Provides comparison methods for UInt. ```APIDOC ## Ord for UInt ### Description Provides ordering comparisons for UInt. ### Method #### cmp `fn cmp(&self, other: &UInt) -> Ordering` Compares `self` and `other` and returns an `Ordering`. ``` ```APIDOC ## Ord for UInt ### Description Provides maximum value comparison for UInt. ### Method #### max `fn max(self, other: Self) -> Self` Compares and returns the maximum of two values. ``` ```APIDOC ## Ord for UInt ### Description Provides minimum value comparison for UInt. ### Method #### min `fn min(self, other: Self) -> Self` Compares and returns the minimum of two values. ``` ```APIDOC ## Ord for UInt ### Description Restricts a value to a certain interval. ### Method #### clamp `fn clamp(self, min: Self, max: Self) -> Self` Restricts a value to be within the specified minimum and maximum bounds. ``` -------------------------------- ### Ordering and Comparison (`Ord`, `PartialOrd`, `PartialEq`) Source: https://docs.rs/chacha20poly1305/latest/chacha20poly1305/consts/type.U514.html Provides methods for comparing UInt values, including checking for equality, determining order, and finding minimum/maximum values. ```APIDOC ## fn cmp(&self, other: &UInt) -> Ordering This method returns an `Ordering` between `self` and `other`. ### Method `cmp` ### Parameters - `other`: `&UInt` - The other UInt value to compare against. ### Response - `Ordering`: An enum value indicating the order relationship (Less, Equal, Greater). ``` ```APIDOC ## fn max(self, other: Self) -> Self Compares and returns the maximum of two values. ### Method `max` ### Parameters - `other`: `Self` - The other UInt value to compare. ### Response - `Self`: The maximum of the two UInt values. ``` ```APIDOC ## fn min(self, other: Self) -> Self Compares and returns the minimum of two values. ### Method `min` ### Parameters - `other`: `Self` - The other UInt value to compare. ### Response - `Self`: The minimum of the two UInt values. ``` ```APIDOC ## fn clamp(self, min: Self, max: Self) -> Self Restrict a value to a certain interval. ### Method `clamp` ### Parameters - `min`: `Self` - The minimum allowed value. - `max`: `Self` - The maximum allowed value. ### Response - `Self`: The clamped UInt value. ``` ```APIDOC ## fn eq(&self, other: &UInt) -> bool Tests for `self` and `other` values to be equal, and is used by `==`. ### Method `eq` ### Parameters - `other`: `&UInt` - The other UInt value to compare. ### Response - `bool`: `true` if the values are equal, `false` otherwise. ``` ```APIDOC ## fn ne(&self, other: &Rhs) -> bool Tests for `!=`. ### Method `ne` ### Parameters - `other`: `&Rhs` - The other value to compare. ### Response - `bool`: `true` if the values are not equal, `false` otherwise. ``` ```APIDOC ## fn partial_cmp(&self, other: &UInt) -> Option This method returns an ordering between `self` and `other` values if one exists. ### Method `partial_cmp` ### Parameters - `other`: `&UInt` - The other UInt value to compare against. ### Response - `Option`: An `Option` containing an `Ordering` if the values are comparable, `None` otherwise. ``` ```APIDOC ## fn lt(&self, other: &Rhs) -> bool Tests less than (for `self` and `other`) and is used by the `<` operator. ### Method `lt` ### Parameters - `other`: `&Rhs` - The other value to compare. ### Response - `bool`: `true` if `self` is less than `other`, `false` otherwise. ``` ```APIDOC ## fn le(&self, other: &Rhs) -> bool Tests less than or equal to (for `self` and `other`) and is used by the `<=` operator. ### Method `le` ### Parameters - `other`: `&Rhs` - The other value to compare. ### Response - `bool`: `true` if `self` is less than or equal to `other`, `false` otherwise. ``` ```APIDOC ## fn gt(&self, other: &Rhs) -> bool Tests greater than (for `self` and `other`) and is used by the `>` operator. ### Method `gt` ### Parameters - `other`: `&Rhs` - The other value to compare. ### Response - `bool`: `true` if `self` is greater than `other`, `false` otherwise. ``` ```APIDOC ## fn ge(&self, other: &Rhs) -> bool Tests greater than or equal to (for `self` and `other`) and is used by the `>=` operator. ### Method `ge` ### Parameters - `other`: `&Rhs` - The other value to compare. ### Response - `bool`: `true` if `self` is greater than or equal to `other`, `false` otherwise. ``` -------------------------------- ### UInt Get Bit Operation Source: https://docs.rs/chacha20poly1305/latest/chacha20poly1305/consts/type.U733.html Retrieves a specific bit from a UInt value. ```APIDOC ## type Output = as Sub>::Output>>::Output Source ``` ```APIDOC ## type Output = Bn Source ``` -------------------------------- ### Bit Extraction Source: https://docs.rs/chacha20poly1305/latest/chacha20poly1305/consts/type.U35184372088831.html Provides methods to get specific bits from a UInt value. ```APIDOC ## Get Bit ### Description Allows for retrieving the value of a specific bit within a `UInt` number. This is achieved by using a bit index. ### Associated Type `type Output = as Sub>::Output>>::Output` (for general `UInt` comparison) `type Output = Bn` (when comparing against `UTerm`) The type of the retrieved bit (typically a boolean or a bit representation). ``` -------------------------------- ### Ordering Implementations Source: https://docs.rs/chacha20poly1305/latest/chacha20poly1305/consts/type.U705.html Provides methods for comparing UInt instances. ```APIDOC ## impl Ord for UInt ### Description Provides total ordering for UInt instances. ### Method `cmp(&self, other: &UInt) -> Ordering` Compares `self` and `other` values. ### Method `max(self, other: Self) -> Self` Returns the maximum of two values. ### Method `min(self, other: Self) -> Self` Returns the minimum of two values. ### Method `clamp(self, min: Self, max: Self) -> Self` Restricts a value to a certain interval. ``` -------------------------------- ### Ordering and Comparison Methods Source: https://docs.rs/chacha20poly1305/latest/chacha20poly1305/consts/type.U58.html Details the methods for comparing UInt instances, including equality, ordering, and clamping values. ```APIDOC ## Ordering and Comparison Methods ### `impl Ord for UInt` #### fn cmp(&self, other: &UInt) -> Ordering This method returns an `Ordering` between `self` and `other`. #### fn max(self, other: Self) -> Self Compares and returns the maximum of two values. #### fn min(self, other: Self) -> Self Compares and returns the minimum of two values. #### fn clamp(self, min: Self, max: Self) -> Self Restrict a value to a certain interval. ### `impl PartialEq for UInt` #### fn eq(&self, other: &UInt) -> bool Tests for `self` and `other` values to be equal, and is used by `==`. #### fn ne(&self, other: &Rhs) -> bool Tests for `!=`. ### `impl PartialOrd for UInt` #### fn partial_cmp(&self, other: &UInt) -> Option This method returns an ordering between `self` and `other` values if one exists. #### fn lt(&self, other: &Rhs) -> bool Tests less than (for `self` and `other`) and is used by the `<` operator. #### fn le(&self, other: &Rhs) -> bool Tests less than or equal to (for `self` and `other`) and is used by the `<=` operator. #### fn gt(&self, other: &Rhs) -> bool Tests greater than (for `self` and `other`) and is used by the `>` operator. #### fn ge(&self, other: &Rhs) -> bool Tests greater than or equal to (for `self` and `other`) and is used by the `>=` operator. ``` -------------------------------- ### Get Bit from UTerm Source: https://docs.rs/chacha20poly1305/latest/chacha20poly1305/consts/type.U1019.html Retrieves a specific bit from a UInt value when the index is UTerm. ```APIDOC ## type Output = Bn ``` -------------------------------- ### Ordering and Comparison Source: https://docs.rs/chacha20poly1305/latest/chacha20poly1305/consts/type.U510.html Details the methods for comparing `UInt` values, including total ordering, finding minimum/maximum, and clamping values within a range. ```APIDOC ## Ordering and Comparison ### Description Provides methods for comparing `UInt` values. ### Methods #### `fn cmp(&self, other: &UInt) -> Ordering` Compares `self` and `other` and returns an `Ordering`. #### `fn max(self, other: Self) -> Self` Returns the maximum of two values. #### `fn min(self, other: Self) -> Self` Returns the minimum of two values. #### `fn clamp(self, min: Self, max: Self) -> Self` Restricts a value to a specified interval. ``` -------------------------------- ### type Output (GetBit) Source: https://docs.rs/chacha20poly1305/latest/chacha20poly1305/consts/type.U817.html The output type when getting a specific bit from a UInt value. ```APIDOC ## type Output (GetBit) ### Description Source ### Signature `type Output = as Sub>::Output>>::Output` ``` -------------------------------- ### KeyInit Trait Implementation for ChaChaPoly1305 Source: https://docs.rs/chacha20poly1305/latest/chacha20poly1305/type.ChaCha8Poly1305.html Provides methods for initializing ChaChaPoly1305 with a key, including creating from a fixed-size key, a slice, or generating a random key. ```APIDOC ### impl KeyInit for ChaChaPoly1305 #### Function: new ```rust fn new(key: &Key) -> Self ``` **Description**: Create new value from fixed size key. #### Function: new_from_slice ```rust fn new_from_slice(key: &[u8]) -> Result ``` **Description**: Create new value from variable size key. #### Function: generate_key ```rust fn generate_key( rng: impl CryptoRng + RngCore, ) -> GenericArray ``` **Availability**: Available on `crate feature 'rand_core'` only. **Description**: Generate random key using the provided `CryptoRng`. ``` -------------------------------- ### Get Bit Operation Source: https://docs.rs/chacha20poly1305/latest/chacha20poly1305/consts/type.U8796093022207.html Provides functionality to retrieve a specific bit from a UInt type. ```APIDOC ## impl GetBit> for UInt Retrieves a bit from a UInt type based on another UInt type. ``` ```APIDOC ## impl GetBit for UInt Retrieves a bit from a UInt type when the index is `UTerm`. ``` -------------------------------- ### PInt Implementations Source: https://docs.rs/chacha20poly1305/latest/chacha20poly1305/consts/type.P443.html Provides details on the implementations available for the generic PInt type, which P443 is an alias for. These include methods for instantiation, arithmetic, comparison, and formatting. ```APIDOC ## Implementations for PInt ### `impl PInt where U: Unsigned + NonZero` #### `pub fn new() -> PInt` Instantiates a singleton representing this strictly positive integer. ### Trait Implementations #### `impl Abs for PInt where U: Unsigned + NonZero` ##### `type Output = PInt` The absolute value. #### `impl Add> for PInt
    where Ul: Unsigned + NonZero + Cmp + PrivateIntegerAdd<
      >::Output, Ur>, Ur: Unsigned + NonZero` ##### `type Output =
        >::Output, Ur>>::Output` The resulting type after applying the `+` operator. ##### `fn add(self, rhs: NInt) -> as Add>>::Output` Performs the `+` operation. #### `impl Add> for PInt
          where Ul: Unsigned + NonZero + Add, Ur: Unsigned + NonZero,
            >::Output: Unsigned + NonZero` ##### `type Output = PInt<
              >::Output>` The resulting type after applying the `+` operator. ##### `fn add(self, _: PInt) -> as Add>>::Output` Performs the `+` operation. #### `impl Add for PInt where U: Unsigned + NonZero` ##### `type Output = PInt` The resulting type after applying the `+` operator. ##### `fn add(self, _: Z0) -> as Add>::Output` Performs the `+` operation. #### `impl Binary for PInt where U: Unsigned + NonZero + Binary` ##### `fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>` Formats the value using the given formatter. #### `impl Clone for PInt where U: Clone + Unsigned + NonZero` ##### `fn clone(&self) -> PInt` Returns a duplicate of the value. ##### `fn clone_from(&mut self, source: &Self)` Performs copy-assignment from `source`. #### `impl Cmp> for PInt

              where P: Unsigned + NonZero, N: Unsigned + NonZero` ##### `type Output = Greater` The result of the comparison. It should only ever be one of `Greater`, `Less`, or `Equal`. #### `impl Cmp> for PInt where Pl: Cmp + Unsigned + NonZero, Pr: Unsigned + NonZero` ##### `type Output = >::Output` The result of the comparison. It should only ever be one of `Greater`, `Less`, or `Equal`. #### `impl Cmp for PInt where U: Unsigned + NonZero` ##### `type Output = Greater` The result of the comparison. It should only ever be one of `Greater`, `Less`, or `Equal`. #### `impl Debug for PInt where U: Debug + Unsigned + NonZero` ##### `fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>` Formats the value using the given formatter. #### `impl Default for PInt where U: Default + Unsigned + NonZero` ##### `fn default() -> PInt` Returns the “default value” for a type. #### `impl Div> for PInt

                where Ul: Unsigned + NonZero + Cmp, Ur: Unsigned + NonZero, PInt
                  : PrivateDivInt<
                    >::Output, NInt>` ##### `type Output = as PrivateDivInt<
                      >::Output, NInt>>::Output` The resulting type after applying the `/` operator. ##### `fn div(self, rhs: NInt) -> as Div>>::Output` Performs the `/` operation. #### `impl Div> for PInt
                        where Ul: Unsigned + NonZero + Cmp, Ur: Unsigned + NonZero, PInt
                          : PrivateDivInt<
                            >::Output, PInt>` ##### `type Output = as PrivateDivInt<
                              >::Output, PInt>>::Output` The resulting type after applying the `/` operator. ##### `fn div(self, rhs: PInt) -> as Div>>::Output` Performs the `/` operation. #### `impl Gcd> for PInt where U1: Unsigned + NonZero + Gcd, U2: Unsigned + NonZero, >::Output: Unsigned + NonZero` ##### `type Output = PInt<>::Output>` The greatest common divisor. #### `impl Gcd> for PInt where U1: Unsigned + NonZero + Gcd, U2: Unsigned + NonZero, >::Output: Unsigned + NonZero` ##### `type Output = PInt<>::Output>` The greatest common divisor. #### `impl Gcd for PInt where U: Unsigned + NonZero` ``` -------------------------------- ### Get Key Size Source: https://docs.rs/chacha20poly1305/latest/chacha20poly1305/struct.ChaChaPoly1305.html Returns the required key size in bytes for the ChaChaPoly1305 algorithm. ```rust fn key_size() -> usize ``` -------------------------------- ### UInt Ordering and Comparison Source: https://docs.rs/chacha20poly1305/latest/chacha20poly1305/consts/type.U4294967296.html Details the methods for comparing `UInt` values, including finding minimum, maximum, and clamping values. ```APIDOC ## UInt Ordering and Comparison This section covers the ordering and comparison functionalities for the `UInt` type. ### `cmp` Compares `self` with `other` and returns an `Ordering`. - **Signature**: `fn cmp(&self, other: &UInt) -> Ordering` ### `max` Returns the maximum of two `UInt` values. - **Signature**: `fn max(self, other: Self) -> Self` ### `min` Returns the minimum of two `UInt` values. - **Signature**: `fn min(self, other: Self) -> Self` ### `clamp` Restricts a `UInt` value to be within a specified interval [`min`, `max`]. - **Signature**: `fn clamp(self, min: Self, max: Self) -> Self` ``` -------------------------------- ### Bit for B1 Methods Source: https://docs.rs/chacha20poly1305/latest/chacha20poly1305/consts/struct.B1.html Provides methods to get the u8 and bool representations of the B1 bit. ```rust fn to_u8() -> u8; fn to_bool() -> bool; ``` -------------------------------- ### impl KeyInit for ChaChaPoly1305 Source: https://docs.rs/chacha20poly1305/latest/chacha20poly1305/trait.KeyInit.html Implementation of the KeyInit trait for the ChaChaPoly1305 type. ```APIDOC ### impl KeyInit for ChaChaPoly1305 (No specific methods documented for this implementation in the provided text beyond the trait's general methods.) ``` -------------------------------- ### Length Calculation for UInt Source: https://docs.rs/chacha20poly1305/latest/chacha20poly1305/consts/type.U35184372088832.html Provides a method to get the length of a UInt instance as a type-level unsigned integer. ```APIDOC ## Length Calculation ### Description Calculates the length of a `UInt` instance. The length is represented as a type-level unsigned integer, determined by the length of the underlying unsigned integer type `U` plus one for the bit `B`. ### Method Signature `fn len(&self) -> as Len>::Output` This function isn’t used in this crate, but may be useful for others. ### Associated Type `Output` `type Output = <::Output as Add>::Output` The length as a type-level unsigned integer. ``` -------------------------------- ### Get Bit Operation for UInt Source: https://docs.rs/chacha20poly1305/latest/chacha20poly1305/consts/type.U35184372088832.html Implements the GetBit operation to retrieve a specific bit from a UInt instance. ```APIDOC ## Get Bit Operation ### Description Retrieves a specific bit from a `UInt` instance. The operation is defined recursively, with a base case for `UTerm` and a general case for `UInt` types. ### General Case - **Associated Type `Output`**: `type Output = as Sub>::Output>>::Output` ### Base Case (`UTerm`) - **Associated Type `Output`**: `type Output = Bn` This operation allows for the inspection of individual bits within the `UInt` value. ``` -------------------------------- ### Ordering and Comparison Implementations Source: https://docs.rs/chacha20poly1305/latest/chacha20poly1305/consts/type.U903.html Provides methods for comparing UInt values, including `cmp`, `max`, `min`, and `clamp`. ```APIDOC ## fn cmp(&self, other: &UInt) -> Ordering ### Description Compares `self` and `other` and returns an `Ordering`. ### Method `cmp` ### Parameters - `self`: The first UInt value. - `other`: The second UInt value to compare against. ``` ```APIDOC ## fn max(self, other: Self) -> Self ### Description Compares two values and returns the maximum. ### Method `max` ### Parameters - `self`: The first UInt value. - `other`: The second UInt value. ``` ```APIDOC ## fn min(self, other: Self) -> Self ### Description Compares two values and returns the minimum. ### Method `min` ### Parameters - `self`: The first UInt value. - `other`: The second UInt value. ``` ```APIDOC ## fn clamp(self, min: Self, max: Self) -> Self ### Description Restricts a value to a certain interval defined by `min` and `max`. ### Method `clamp` ### Parameters - `self`: The value to clamp. - `min`: The minimum allowed value. - `max`: The maximum allowed value. ``` -------------------------------- ### Get Bit with UTerm Source: https://docs.rs/chacha20poly1305/latest/chacha20poly1305/consts/type.U262143.html Retrieves a specific bit from a UInt value when the position is `UTerm`. The result is the `Bit` value `Bn`. ```APIDOC #### type Output = Bn ``` -------------------------------- ### PInt Ordering Implementations Source: https://docs.rs/chacha20poly1305/latest/chacha20poly1305/consts/type.P68719476736.html Provides methods for comparing PInt instances, including checking for equality, inequality, and determining the order (less than, greater than, equal to, etc.). ```APIDOC ## PInt Ordering and Comparison ### Description Implements comparison traits for the `PInt` type, allowing instances to be ordered and checked for equality. ### Methods #### `cmp(&self, other: &PInt) -> Ordering` Compares `self` with `other` and returns an `Ordering`. #### `partial_cmp(&self, other: &PInt) -> Option` Compares `self` with `other` and returns an `Option` if a comparison is possible. #### `eq(&self, other: &PInt) -> bool` Tests if `self` is equal to `other`. #### `ne(&self, other: &Rhs) -> bool` Tests if `self` is not equal to `other`. #### `lt(&self, other: &Rhs) -> bool` Tests if `self` is less than `other`. #### `le(&self, other: &Rhs) -> bool` Tests if `self` is less than or equal to `other`. #### `gt(&self, other: &Rhs) -> bool` Tests if `self` is greater than `other`. #### `ge(&self, other: &Rhs) -> bool` Tests if `self` is greater than or equal to `other`. ``` -------------------------------- ### PInt Ordering Implementation Source: https://docs.rs/chacha20poly1305/latest/chacha20poly1305/consts/type.P2147483647.html Provides methods for comparing PInt instances, including `cmp` for total ordering, `max` and `min` for finding extremes, and `clamp` for restricting values within an interval. ```APIDOC ## `cmp` ### Description Compares `self` with `other` and returns an `Ordering`. ### Signature `fn cmp(&self, other: &PInt) -> Ordering` ## `max` ### Description Compares `self` and `other` and returns the maximum value. ### Signature `fn max(self, other: Self) -> Self` ## `min` ### Description Compares `self` and `other` and returns the minimum value. ### Signature `fn min(self, other: Self) -> Self` ## `clamp` ### Description Restricts a value to a certain interval defined by `min` and `max`. ### Signature `fn clamp(self, min: Self, max: Self) -> Self` ``` -------------------------------- ### Get Bit Operation Source: https://docs.rs/chacha20poly1305/latest/chacha20poly1305/consts/type.U1152921504606846976.html Implements the `GetBit` trait for UInt types, allowing retrieval of a specific bit at a given position. ```APIDOC ## Get Bit Operation ### Description Provides functionality to retrieve a specific bit from a `UInt` type at a given index. The `Output` type alias indicates the type of the retrieved bit. ### Type Aliases - `type Output = as Sub>::Output>>::Output` (for `GetBit>`) - `type Output = Bn` (for `GetBit`) ``` -------------------------------- ### Ordering Implementations Source: https://docs.rs/chacha20poly1305/latest/chacha20poly1305/consts/type.U851.html Provides methods for comparing UInt values, including `cmp`, `max`, `min`, and `clamp`. ```APIDOC ## fn cmp(&self, other: &UInt) -> Ordering ### Description Compares `self` and `other` values and returns an `Ordering`. ### Method `cmp` ### Parameters - `self`: A reference to the first UInt value. - `other`: A reference to the second UInt value. ### Returns An `Ordering` enum value. ``` ```APIDOC ## fn max(self, other: Self) -> Self ### Description Compares two UInt values and returns the maximum. ### Method `max` ### Parameters - `self`: The first UInt value. - `other`: The second UInt value. ### Returns The maximum of the two values. ``` ```APIDOC ## fn min(self, other: Self) -> Self ### Description Compares two UInt values and returns the minimum. ### Method `min` ### Parameters - `self`: The first UInt value. - `other`: The second UInt value. ### Returns The minimum of the two values. ``` ```APIDOC ## fn clamp(self, min: Self, max: Self) -> Self ### Description Restricts a UInt value to a certain interval defined by `min` and `max`. ### Method `clamp` ### Parameters - `self`: The value to clamp. - `min`: The minimum allowed value. - `max`: The maximum allowed value. ### Returns The clamped value. ``` -------------------------------- ### Integer Conversion (i8) Source: https://docs.rs/chacha20poly1305/latest/chacha20poly1305/consts/type.U1024.html Converts a UInt to an i8. The `to_int` method provides a way to get the concrete i8 value. ```APIDOC ## fn to_int() -> i8 Method returning the concrete value for the type as i8. ### Returns The i8 representation of the UInt. ``` -------------------------------- ### Integer Conversion (i64) Source: https://docs.rs/chacha20poly1305/latest/chacha20poly1305/consts/type.U1024.html Converts a UInt to an i64. The `to_int` method provides a way to get the concrete i64 value. ```APIDOC ## fn to_int() -> i64 Method returning the concrete value for the type as i64. ### Returns The i64 representation of the UInt. ``` -------------------------------- ### PInt Implementations Source: https://docs.rs/chacha20poly1305/latest/chacha20poly1305/consts/type.P692.html Provides details on the implementations available for the PInt type, which P692 is an alias for. This includes methods for instantiation, arithmetic operations, comparisons, and more. ```APIDOC ## Type Alias P692 `pub type P692 = PInt, B0>, B1>, B0>, B1>, B1>, B0>, B1>, B0>, B0>>;` This is a type alias for `PInt` with a specific unsigned integer configuration. ### Aliased Type ```rust pub struct P692 { /* private fields */ } ``` ### Implementations for PInt #### `pub fn new() -> PInt` Instantiates a singleton representing this strictly positive integer. #### `impl Abs for PInt` - **type Output**: `PInt` - The absolute value. #### `impl Add> for PInt
                                ` - **type Output**: `
                                  >::Output, Ur>>::Output` - The resulting type after applying the `+` operator. - **fn add(self, rhs: NInt) -> ...** Performs the `+` operation. #### `impl Add> for PInt
                                    ` - **type Output**: `PInt<
                                      >::Output>` - The resulting type after applying the `+` operator. - **fn add(self, _: PInt) -> ...** Performs the `+` operation. #### `impl Add for PInt` - **type Output**: `PInt` - The resulting type after applying the `+` operator. - **fn add(self, _: Z0) -> ...** Performs the `+` operation. #### `impl Binary for PInt` - **fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>** Formats the value using the given formatter. #### `impl Clone for PInt` - **fn clone(&self) -> PInt** Returns a duplicate of the value. - **fn clone_from(&mut self, source: &Self)** Performs copy-assignment from `source`. #### `impl Cmp> for PInt

                                      ` - **type Output**: `Greater` - The result of the comparison. #### `impl Cmp> for PInt` - **type Output**: `>::Output` - The result of the comparison. #### `impl Cmp for PInt` - **type Output**: `Greater` - The result of the comparison. #### `impl Debug for PInt` - **fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>** Formats the value using the given formatter. #### `impl Default for PInt` - **fn default() -> PInt** Returns the “default value” for a type. #### `impl Div> for PInt

                                        ` - **type Output**: ` as PrivateDivInt<
                                          >::Output, NInt>>::Output` - The resulting type after applying the `/` operator. - **fn div(self, rhs: NInt) -> ...** Performs the `/` operation. #### `impl Div> for PInt
                                            ` - **type Output**: ` as PrivateDivInt<
                                              >::Output, PInt>>::Output` - The resulting type after applying the `/` operator. - **fn div(self, rhs: PInt) -> ...** Performs the `/` operation. #### `impl Gcd> for PInt` - **type Output**: `PInt<>::Output>` - The greatest common divisor. #### `impl Gcd> for PInt` - **type Output**: `PInt<>::Output>` - The greatest common divisor. #### `impl Gcd for PInt` ``` -------------------------------- ### Integer Conversion (i32) Source: https://docs.rs/chacha20poly1305/latest/chacha20poly1305/consts/type.U1024.html Converts a UInt to an i32. The `to_int` method provides a way to get the concrete i32 value. ```APIDOC ## fn to_int() -> i32 Method returning the concrete value for the type as i32. ### Returns The i32 representation of the UInt. ``` -------------------------------- ### Ordering Implementations Source: https://docs.rs/chacha20poly1305/latest/chacha20poly1305/consts/type.U937.html Provides methods for comparing UInt values. ```APIDOC ## fn cmp(&self, other: &UInt) -> Ordering ### Description Compares `self` and `other` and returns an `Ordering`. ### Method `cmp` ### Parameters - `self`: The first UInt value. - `other`: The second UInt value to compare against. ### Returns An `Ordering` enum variant (`Less`, `Equal`, `Greater`). ``` ```APIDOC ## fn max(self, other: Self) -> Self ### Description Compares two `UInt` values and returns the maximum. ### Method `max` ### Parameters - `self`: The first UInt value. - `other`: The second UInt value. ### Returns The maximum of the two `UInt` values. ``` ```fn min(self, other: Self) -> Self ### Description Compares two `UInt` values and returns the minimum. ### Method `min` ### Parameters - `self`: The first UInt value. - `other`: The second UInt value. ### Returns The minimum of the two `UInt` values. ## fn clamp(self, min: Self, max: Self) -> Self ### Description Restricts a `UInt` value to be within a specified interval. ### Method `clamp` ### Parameters - `self`: The `UInt` value to clamp. - `min`: The minimum allowed value. - `max`: The maximum allowed value. ### Returns The clamped `UInt` value. ``` -------------------------------- ### PInt Ordering Implementation Source: https://docs.rs/chacha20poly1305/latest/chacha20poly1305/consts/type.P486.html Provides methods for comparing PInt values, including comparison, finding the maximum, and finding the minimum. ```APIDOC ## Ord for PInt ### Description Implements ordering comparisons for `PInt`. ### Methods - `cmp(&self, other: &PInt) -> Ordering`: Compares `self` and `other` and returns an `Ordering`. - `max(self, other: Self) -> Self`: Returns the maximum of two values. ``` -------------------------------- ### Integer Conversion (i16) Source: https://docs.rs/chacha20poly1305/latest/chacha20poly1305/consts/type.U1024.html Converts a UInt to an i16. The `to_int` method provides a way to get the concrete i16 value. ```APIDOC ## fn to_int() -> i16 Method returning the concrete value for the type as i16. ### Returns The i16 representation of the UInt. ``` -------------------------------- ### ToInt Source: https://docs.rs/chacha20poly1305/latest/chacha20poly1305/consts/type.P1048576.html Provides a constant `INT` and a method `to_int()` to get the concrete `i32` value of a PInt type. ```APIDOC ## ToInt ### Description Provides a constant `INT` and a method `to_int()` to get the concrete `i32` value of a PInt type. ### Type Constraints `where U: Unsigned + NonZero` ### Constant `INT: i32` - The concrete value for the type. Can be used in `const` contexts. ### Method `to_int() -> i32` - Method returning the concrete value for the type. ``` -------------------------------- ### Comparison (`cmp`, `max`, `min`, `clamp`, `eq`, `ne`, `partial_cmp`, `lt`, `le`, `gt`, `ge`) Source: https://docs.rs/chacha20poly1305/latest/chacha20poly1305/consts/type.U516.html Details the comparison methods available for the UInt type, including ordering, equality, and range clamping. ```APIDOC ## Comparison Operations This section covers the various comparison operations supported by the `UInt` type. ### `impl Ord for UInt` Implements the `Ord` trait for `UInt` types, enabling total ordering comparisons. #### `fn cmp(&self, other: &UInt) -> Ordering` Compares `self` and `other` and returns an `Ordering`. #### `fn max(self, other: Self) -> Self` Returns the maximum of two values. #### `fn min(self, other: Self) -> Self` Returns the minimum of two values. #### `fn clamp(self, min: Self, max: Self) -> Self` Restricts a value to a certain interval. ### `impl PartialEq for UInt` Implements the `PartialEq` trait for `UInt` types, enabling equality checks. #### `fn eq(&self, other: &UInt) -> bool` Tests if `self` and `other` values are equal. #### `fn ne(&self, other: &Rhs) -> bool` Tests if `self` and `other` values are not equal. ### `impl PartialOrd for UInt` Implements the `PartialOrd` trait for `UInt` types, enabling partial ordering comparisons. #### `fn partial_cmp(&self, other: &UInt) -> Option` Returns an ordering between `self` and `other` if one exists. #### `fn lt(&self, other: &Rhs) -> bool` Tests if `self` is less than `other`. #### `fn le(&self, other: &Rhs) -> bool` Tests if `self` is less than or equal to `other`. #### `fn gt(&self, other: &Rhs) -> bool` Tests if `self` is greater than `other`. #### `fn ge(&self, other: &Rhs) -> bool` Tests if `self` is greater than or equal to `other`. ``` -------------------------------- ### PInt Comparison Methods Source: https://docs.rs/chacha20poly1305/latest/chacha20poly1305/consts/type.P936.html Provides methods for comparing PInt values, including finding the minimum, clamping a value within a range, and testing for equality and inequality. ```APIDOC ## PInt Comparison ### Methods - **`min(self, other: Self) -> Self`**: Compares two values and returns the minimum. - **`clamp(self, min: Self, max: Self) -> Self`**: Restricts a value to a specified interval. - **`eq(&self, other: &PInt) -> bool`**: Tests if `self` and `other` values are equal. Used by `==`. - **`ne(&self, other: &Rhs) -> bool`**: Tests for inequality (`!=`). - **`partial_cmp(&self, other: &PInt) -> Option`**: Returns an ordering between `self` and `other` if one exists. - **`lt(&self, other: &Rhs) -> bool`**: Tests if `self` is less than `other`. Used by `<`. - **`le(&self, other: &Rhs) -> bool`**: Tests if `self` is less than or equal to `other`. Used by `<=`. - **`gt(&self, other: &Rhs) -> bool`**: Tests if `self` is greater than `other`. Used by `>`. - **`ge(&self, other: &Rhs) -> bool`**: Tests if `self` is greater than or equal to `other`. Used by `>=`. ``` -------------------------------- ### ToInt Source: https://docs.rs/chacha20poly1305/latest/chacha20poly1305/consts/type.P1048576.html Provides a constant `INT` and a method `to_int()` to get the concrete `i16` value of a PInt type. ```APIDOC ## ToInt ### Description Provides a constant `INT` and a method `to_int()` to get the concrete `i16` value of a PInt type. ### Type Constraints `where U: Unsigned + NonZero` ### Constant `INT: i16` - The concrete value for the type. Can be used in `const` contexts. ### Method `to_int() -> i16` - Method returning the concrete value for the type. ```