### Get mutable reference to last element Source: https://docs.rs/gss-api/latest/gss_api/negotiation/type.MechTypeList.html Use `peek_mut` to get a mutable reference to the last element without removing it. Returns `None` if the vector is empty. This is an experimental API. ```rust #![feature(vec_peek_mut)] let mut vec = Vec::new(); assert!(vec.peek_mut().is_none()); vec.push(1); vec.push(5); vec.push(2); assert_eq!(vec.last(), Some(&2)); if let Some(mut val) = vec.peek_mut() { *val = 0; } assert_eq!(vec.last(), Some(&0)); ``` -------------------------------- ### Create Vec with System Allocator (Nightly) Source: https://docs.rs/gss-api/latest/gss_api/negotiation/type.MechTypeList.html Demonstrates creating a new, empty Vec with the System allocator. This API is experimental and requires the `allocator_api` feature. ```rust #![feature(allocator_api)] use std::alloc::System; let mut vec: Vec = Vec::new_in(System); ``` -------------------------------- ### Create Vec from raw parts with System allocator Source: https://docs.rs/gss-api/latest/gss_api/negotiation/type.MechTypeList.html Demonstrates creating a `Vec` from raw parts obtained from an existing `Vec` using `mem::ManuallyDrop` and then rebuilding it with `Vec::from_raw_parts_in`. Ensure all safety invariants are met before calling. ```rust #![feature(allocator_api)] use std::alloc::System; use std::ptr; use std::mem; let mut v = Vec::with_capacity_in(3, System); v.push(1); v.push(2); v.push(3); // Prevent running `v`'s destructor so we are in complete control // of the allocation. let mut v = mem::ManuallyDrop::new(v); // Pull out the various important pieces of information about `v` let p = v.as_mut_ptr(); let len = v.len(); let cap = v.capacity(); let alloc = v.allocator(); unsafe { // Overwrite memory with 4, 5, 6 for i in 0..len { ptr::write(p.add(i), 4 + i); } // Put everything back together into a Vec let rebuilt = Vec::from_raw_parts_in(p, len, cap, alloc.clone()); assert_eq!(rebuilt, [4, 5, 6]); } ``` -------------------------------- ### Get Vec Length Source: https://docs.rs/gss-api/latest/gss_api/negotiation/type.MechTypeList.html Returns the number of elements currently in the vector. ```rust let a = vec![1, 2, 3]; assert_eq!(a.len(), 3); ``` -------------------------------- ### Tagged Implementation Source: https://docs.rs/gss-api/latest/gss_api/type.PerMsgToken.html Provides a method to get the ASN.1 tag of an AnyRef. ```APIDOC ## impl Tagged for AnyRef<'_> ### fn tag(&self) -> Tag Get the ASN.1 tag that this type is encoded with. ``` -------------------------------- ### CloneToUninit implementation Source: https://docs.rs/gss-api/latest/gss_api/negotiation/struct.NegHints.html Implements the experimental clone_to_uninit method for efficient copying to uninitialized memory. ```rust unsafe fn clone_to_uninit(&self, dest: *mut u8) ``` -------------------------------- ### BitString::bit_len Method Source: https://docs.rs/gss-api/latest/gss_api/negotiation/type.ContextFlags.html Gets the total length of the BitString in bits. ```rust pub fn bit_len(&self) -> usize; ``` -------------------------------- ### Ordering and Comparison Source: https://docs.rs/gss-api/latest/gss_api/type.SealedMessage.html Details the methods available for comparing AnyRef instances, including total ordering, maximum, minimum, clamping, and partial comparison. ```APIDOC ## impl<'a> Ord for AnyRef<'a> #### fn cmp(&self, other: &AnyRef<'a>) -> 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<'a> PartialOrd for AnyRef<'a> #### fn partial_cmp(&self, other: &AnyRef<'a>) -> 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. ## impl ValueOrd for AnyRef<'_> #### fn value_cmp(&self, other: &AnyRef<'_>) -> Result Return an `Ordering` between value portion of TLV-encoded `self` and `other` when serialized as ASN.1 DER. ``` -------------------------------- ### Get NegTokenTarg Header Source: https://docs.rs/gss-api/latest/gss_api/negotiation/struct.NegTokenTarg.html Retrieves the ASN.1 DER Header for the NegTokenTarg value. ```rust fn header(&self) -> Result ``` -------------------------------- ### Conversions Source: https://docs.rs/gss-api/latest/gss_api/type.SealedMessage.html Demonstrates how AnyRef can be created from other string types like Utf8StringRef and VideotexStringRef, and how it can be converted from a byte slice. ```APIDOC ## fn from(utf_string: Utf8StringRef<'a>) -> AnyRef<'a> Converts to this type from the input type. ## impl<'a> From> for AnyRef<'a> #### fn from(printable_string: VideotexStringRef<'a>) -> AnyRef<'a> Converts to this type from the input type. ## impl<'a> TryFrom<&'a [u8]> for AnyRef<'a> #### fn try_from(bytes: &'a [u8]) -> Result, Error> Performs the conversion. #### type Error = Error The type returned in the event of a conversion error. ``` -------------------------------- ### Tagged Trait Source: https://docs.rs/gss-api/latest/gss_api/negotiation/enum.NegResult.html Provides a method for getting the ASN.1 tag that this type is encoded with. ```APIDOC ## fn tag(&self) -> Tag ### Description Get the ASN.1 tag that this type is encoded with. ### Method `tag` ``` -------------------------------- ### AnyRef Methods Source: https://docs.rs/gss-api/latest/gss_api/type.SealedMessage.html Provides core functionality for working with AnyRef, including creation, value retrieval, decoding, and type checking. ```APIDOC ## Implementations for AnyRef<'a> ### `pub const NULL: AnyRef<'a>` `AnyRef` representation of the ASN.1 `NULL` type. ### `pub fn new(tag: Tag, bytes: &'a [u8]) -> Result, Error>` Create a new `AnyRef` from the provided `Tag` and DER bytes. ### `pub fn value(self) -> &'a [u8]` Get the raw value for this `AnyRef` type as a byte slice. ### `pub fn decode_as(self) -> Result where T: Choice<'a> + DecodeValue<'a>` Attempt to decode this `AnyRef` type into the inner value. ### `pub fn is_null(self) -> bool` Is this value an ASN.1 `NULL` value? ### `pub fn sequence(self, f: F) -> Result where F: FnOnce(&mut SliceReader<'a>) -> Result` Attempt to decode this value an ASN.1 `SEQUENCE`, creating a new nested reader and calling the provided argument with it. ``` -------------------------------- ### Get Underlying Allocator Reference Source: https://docs.rs/gss-api/latest/gss_api/negotiation/type.MechTypeList.html Retrieves a reference to the vector's allocator. This is an experimental API. ```rust let allocator_ref = my_vec.allocator(); ``` -------------------------------- ### From<&'a Ia5String> for AnyRef<'a> Source: https://docs.rs/gss-api/latest/gss_api/type.SealedMessage.html Conversion implementation from a reference to an Ia5String into an AnyRef. ```rust fn from(international_string: &'a Ia5String) -> AnyRef<'a> ``` -------------------------------- ### Get NegotiationToken Header Source: https://docs.rs/gss-api/latest/gss_api/negotiation/enum.NegotiationToken.html Retrieves the ASN.1 Header for encoding a NegotiationToken. Requires the `rfc2478` feature. ```rust fn header(&self) -> Result ``` -------------------------------- ### Construct Vec from raw parts with custom allocator Source: https://docs.rs/gss-api/latest/gss_api/negotiation/type.MechTypeList.html Demonstrates reconstructing a Vec from its raw pointer, length, capacity, and allocator. Ensure all safety invariants are met before calling. ```rust #![feature(allocator_api, box_vec_non_null)] use std::alloc.System; use std::ptr.NonNull; use std::mem; let mut v = Vec::with_capacity_in(3, System); v.push(1); v.push(2); v.push(3); // Prevent running `v`'s destructor so we are in complete control // of the allocation. let mut v = mem::ManuallyDrop::new(v); // Pull out the various important pieces of information about `v` let p = unsafe { NonNull::new_unchecked(v.as_mut_ptr()) }; let len = v.len(); let cap = v.capacity(); let alloc = v.allocator(); unsafe { // Overwrite memory with 4, 5, 6 for i in 0..len { p.add(i).write(4 + i); } // Put everything back together into a Vec let rebuilt = Vec::from_parts_in(p, len, cap, alloc.clone()); assert_eq!(rebuilt, [4, 5, 6]); } ``` -------------------------------- ### Get AnyRef Value Source: https://docs.rs/gss-api/latest/gss_api/type.SealedMessage.html Retrieves the raw byte slice representing the value of this AnyRef. This is a simple getter method. ```rust pub fn value(self) -> &'a [u8] ``` -------------------------------- ### PartialEq Implementation Source: https://docs.rs/gss-api/latest/gss_api/struct.InitialContextToken.html Enables equality comparison for `InitialContextToken` instances. ```APIDOC fn eq(&self, other: &InitialContextToken<'a>) -> bool Tests for `self` and `other` values to be equal, and is used by `==`. const fn ne(&self, other: &Rhs) -> bool Tests for `!=`. ``` -------------------------------- ### Get Header for Encoding AnyRef Source: https://docs.rs/gss-api/latest/gss_api/type.PerMsgToken.html Retrieves the Header used for encoding this AnyRef value. Requires the type to implement the Tagged trait. ```rust fn header(&self) -> Result where Self: Tagged, ``` -------------------------------- ### From<&'a Any> for AnyRef<'a> Source: https://docs.rs/gss-api/latest/gss_api/type.SealedMessage.html Conversion implementation from a reference to an Any type into an AnyRef. ```rust fn from(any: &'a Any) -> AnyRef<'a> ``` -------------------------------- ### EncodeValue for AnyRef Source: https://docs.rs/gss-api/latest/gss_api/type.SealedMessage.html Implements the EncodeValue trait for AnyRef, providing methods to compute value length and encode the value to a Writer, including getting the Header. ```rust fn value_len(&self) -> Result ``` ```rust fn encode_value(&self, writer: &mut impl Writer) -> Result<(), Error> ``` ```rust fn header(&self) -> Result where Self: Tagged ``` -------------------------------- ### TryFrom Implementation Source: https://docs.rs/gss-api/latest/gss_api/type.PerMsgToken.html Provides a method to attempt conversion from a byte slice to AnyRef. ```APIDOC ## impl<'a> TryFrom<&'a [u8]> for AnyRef<'a> ### type Error = Error The type returned in the event of a conversion error. ### fn try_from(bytes: &'a [u8]) -> Result, Error> Performs the conversion. ``` -------------------------------- ### PartialEq ne implementation for NegHints Source: https://docs.rs/gss-api/latest/gss_api/negotiation/struct.NegHints.html Implements the ne method for PartialEq on NegHints, testing for inequality. ```rust const fn ne(&self, other: &Rhs) -> bool ``` -------------------------------- ### Get Vec capacity Source: https://docs.rs/gss-api/latest/gss_api/negotiation/type.MechTypeList.html The `capacity` method returns the total number of elements the vector can hold without reallocating. For zero-sized elements, the capacity is `usize::MAX`. ```rust let mut vec: Vec = Vec::with_capacity(10); vec.push(42); assert!(vec.capacity() >= 10); ``` ```rust #[derive(Clone)] struct ZeroSized; fn main() { assert_eq!(std::mem::size_of::(), 0); let v = vec![ZeroSized; 0]; assert_eq!(v.capacity(), usize::MAX); } ``` -------------------------------- ### From> for Vec Source: https://docs.rs/gss-api/latest/gss_api/negotiation/type.MechTypeList.html Converts a BinaryHeap into a Vec without data movement. ```APIDOC ## fn from(heap: BinaryHeap) -> Vec ### Description Converts a `BinaryHeap` into a `Vec`. This conversion requires no data movement or allocation, and has constant time complexity. ### Parameters #### Path Parameters - None #### Query Parameters - None #### Request Body - None ### Request Example None ### Response #### Success Response (200) - `Vec`: The vector representation of the binary heap. #### Response Example None ``` -------------------------------- ### Split Vec with Range Argument Source: https://docs.rs/gss-api/latest/gss_api/negotiation/type.MechTypeList.html Splits a vector by applying `extract_if` to a specified range. This example extracts elements equal to 1 from the 7th element onwards. ```rust let mut items = vec![0, 0, 0, 0, 0, 0, 0, 1, 2, 1, 2, 1, 2]; let ones = items.extract_if(7.., |x| *x == 1).collect::>(); assert_eq!(items, vec![0, 0, 0, 0, 0, 0, 0, 2, 2, 2]); assert_eq!(ones.len(), 3); ``` -------------------------------- ### Clone Implementation Source: https://docs.rs/gss-api/latest/gss_api/struct.InitialContextToken.html Provides methods for cloning an `InitialContextToken`. ```APIDOC fn clone(&self) -> InitialContextToken<'a> Returns a duplicate of the value. const fn clone_from(&mut self, source: &Self) Performs copy-assignment from `source`. ``` -------------------------------- ### Get Non-Null Pointer to Vector Buffer (Nightly) Source: https://docs.rs/gss-api/latest/gss_api/negotiation/type.MechTypeList.html Returns a NonNull pointer to the vector's buffer. Use this when the vector must outlive the pointer, and be aware that modifications to the vector can invalidate the pointer. ```rust #![feature(box_vec_non_null)] // Allocate vector big enough for 4 elements. let size = 4; let mut x: Vec = Vec::with_capacity(size); let x_ptr = x.as_non_null(); // Initialize elements via raw pointer writes, then set length. unsafe { for i in 0..size { x_ptr.add(i).write(i as i32); } x.set_len(size); } assert_eq!(&*x, &[0, 1, 2, 3]); ``` ```rust #![feature(box_vec_non_null)] unsafe { let mut v = vec![0]; let ptr1 = v.as_non_null(); ptr1.write(1); let ptr2 = v.as_non_null(); ptr2.write(2); // Notably, the write to `ptr2` did *not* invalidate `ptr1`: ptr1.write(3); } ``` -------------------------------- ### Debug Implementation Source: https://docs.rs/gss-api/latest/gss_api/struct.InitialContextToken.html Allows `InitialContextToken` to be formatted for debugging. ```APIDOC fn fmt(&self, f: &mut Formatter<'_>) -> Result Formats the value using the given formatter. ``` -------------------------------- ### Get Raw Pointer to Vector Buffer Source: https://docs.rs/gss-api/latest/gss_api/negotiation/type.MechTypeList.html Returns a raw pointer to the vector's buffer. The caller must ensure the vector outlives the pointer and that the memory is not mutated through this pointer if aliasing guarantees are relied upon. ```rust let x = vec![1, 2, 4]; let x_ptr = x.as_ptr(); unsafe { for i in 0..x.len() { assert_eq!(*x_ptr.add(i), 1 << i); } } ``` ```rust unsafe { let mut v = vec![0, 1, 2]; let ptr1 = v.as_ptr(); let _ = ptr1.read(); let ptr2 = v.as_mut_ptr().offset(2); ptr2.write(2); // Notably, the write to `ptr2` did *not* invalidate `ptr1` // because it mutated a different element: let _ = ptr1.read(); } ``` -------------------------------- ### Get Mutable Raw Pointer to Vector Buffer Source: https://docs.rs/gss-api/latest/gss_api/negotiation/type.MechTypeList.html Returns a raw mutable pointer to the vector's buffer. The caller must ensure the vector outlives the pointer and that the memory is not mutated through other means that could invalidate this pointer. ```rust // Allocate vector big enough for 4 elements. let size = 4; let mut x: Vec = Vec::with_capacity(size); let x_ptr = x.as_mut_ptr(); // Initialize elements via raw pointer writes, then set length. unsafe { for i in 0..size { *x_ptr.add(i) = i as i32; } x.set_len(size); } assert_eq!(&*x, &[0, 1, 2, 3]); ``` ```rust unsafe { let mut v = vec![0]; let ptr1 = v.as_mut_ptr(); ptr1.write(1); let ptr2 = v.as_mut_ptr(); ptr2.write(2); // Notably, the write to `ptr2` did *not* invalidate `ptr1`: ptr1.write(3); } ``` -------------------------------- ### Create Vec with TryWithCapacity (Nightly) Source: https://docs.rs/gss-api/latest/gss_api/negotiation/type.MechTypeList.html Constructs a new, empty Vec with a specified initial capacity, returning a Result. This is a nightly-only experimental API that allows handling allocation failures. ```rust pub fn try_with_capacity(capacity: usize) -> Result, TryReserveError> ``` -------------------------------- ### From<()> for AnyRef<'a> Source: https://docs.rs/gss-api/latest/gss_api/type.SealedMessage.html Conversion implementation from the unit type () into an AnyRef. ```rust fn from(_: ()) -> AnyRef<'a> ``` -------------------------------- ### PartialEq Implementation Source: https://docs.rs/gss-api/latest/gss_api/type.PerMsgToken.html Provides methods for checking equality between AnyRef instances. ```APIDOC ## impl<'a> PartialEq for AnyRef<'a> ### fn eq(&self, other: &AnyRef<'a>) -> bool Tests for `self` and `other` values to be equal, and is used by `==`. ### const fn ne(&self, other: &Rhs) -> bool Tests for `!=`. The default implementation is almost always sufficient, and should not be overridden without very good reason. ``` -------------------------------- ### pub fn split_at_spare_mut(&mut self) -> (&mut [T], &mut [MaybeUninit]) Source: https://docs.rs/gss-api/latest/gss_api/negotiation/type.MechTypeList.html This is a nightly-only experimental API. It returns the vector's content as a slice of `T` and the remaining spare capacity as a slice of `MaybeUninit`. Use with care for optimization; prefer standard methods like `push` or `extend` for general appending. ```APIDOC ## pub fn split_at_spare_mut(&mut self) -> (&mut [T], &mut [MaybeUninit]) ### Description Returns vector content as a slice of `T`, along with the remaining spare capacity of the vector as a slice of `MaybeUninit`. The returned spare capacity slice can be used to fill the vector with data (e.g. by reading from a file) before marking the data as initialized using the `set_len` method. Note that this is a low-level API, which should be used with care for optimization purposes. If you need to append data to a `Vec` you can use `push`, `extend`, `extend_from_slice`, `extend_from_within`, `insert`, `append`, `resize` or `resize_with`, depending on your exact needs. ### Examples ```rust #![feature(vec_split_at_spare)] let mut v = vec![1, 1, 2]; // Reserve additional space big enough for 10 elements. v.reserve(10); let (init, uninit) = v.split_at_spare_mut(); let sum = init.iter().copied().sum::(); // Fill in the next 4 elements. uninit[0].write(sum); uninit[1].write(sum * 2); uninit[2].write(sum * 3); uninit[3].write(sum * 4); // Mark the 4 elements of the vector as being initialized. unsafe { let len = v.len(); v.set_len(len + 4); } assert_eq!(&v, &[1, 1, 2, 4, 8, 12, 16]); ``` ``` -------------------------------- ### From<&'a PrintableString> for AnyRef<'a> Source: https://docs.rs/gss-api/latest/gss_api/type.SealedMessage.html Conversion implementation from a reference to a PrintableString into an AnyRef. ```rust fn from(printable_string: &'a PrintableString) -> AnyRef<'a> ``` -------------------------------- ### From> for AnyRef<'a> Source: https://docs.rs/gss-api/latest/gss_api/type.SealedMessage.html Conversion implementation from an Ia5StringRef into an AnyRef. ```rust fn from(internationalized_string: Ia5StringRef<'a>) -> AnyRef<'a> ``` -------------------------------- ### Ord Implementation Source: https://docs.rs/gss-api/latest/gss_api/type.PerMsgToken.html Provides methods for ordering AnyRef instances. ```APIDOC ## impl<'a> Ord for AnyRef<'a> ### fn cmp(&self, other: &AnyRef<'a>) -> 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. ``` -------------------------------- ### from Source: https://docs.rs/gss-api/latest/gss_api/type.PerMsgToken.html Converts to AnyRef from a printable string representation. ```APIDOC ## fn from(printable_string: VideotexStringRef<'a>) -> AnyRef<'a> Converts to this type from the input type. ``` -------------------------------- ### AnyRef Implementations for SubsequentContextToken Source: https://docs.rs/gss-api/latest/gss_api/type.SubsequentContextToken.html Details the methods and trait implementations available for AnyRef, which underlies SubsequentContextToken. ```APIDOC ## Aliased Type ```rust pub struct SubsequentContextToken<'a> { /* private fields */ } ``` ## Implementations ### impl<'a> AnyRef<'a> #### pub const NULL: AnyRef<'a> `AnyRef` representation of the ASN.1 `NULL` type. #### pub fn new(tag: Tag, bytes: &'a [u8]) -> Result, Error> Create a new `AnyRef` from the provided `Tag` and DER bytes. #### pub fn value(self) -> &'a [u8] Get the raw value for this `AnyRef` type as a byte slice. #### pub fn decode_as(self) -> Result where T: Choice<'a> + DecodeValue<'a>, Attempt to decode this `AnyRef` type into the inner value. #### pub fn is_null(self) -> bool Is this value an ASN.1 `NULL` value? #### pub fn sequence(self, f: F) -> Result where F: FnOnce(&mut SliceReader<'a>) -> Result, Attempt to decode this value an ASN.1 `SEQUENCE`, creating a new nested reader and calling the provided argument with it. ### impl<'a> Choice<'a> for AnyRef<'a> #### fn can_decode(_: Tag) -> bool Is the provided `Tag` decodable as a variant of this `CHOICE`? ### impl<'a> Clone for AnyRef<'a> #### fn clone(&self) -> AnyRef<'a> Returns a duplicate of the value. #### const fn clone_from(&mut self, source: &Self) Performs copy-assignment from `source`. ### impl<'a> Debug for AnyRef<'a> #### fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error> Formats the value using the given formatter. ### impl<'a> Decode<'a> for AnyRef<'a> #### fn decode(reader: &mut R) -> Result, Error> where R: Reader<'a>, Attempt to decode this message using the provided decoder. #### fn from_der(bytes: &'a [u8]) -> Result Parse `Self` from the provided DER-encoded byte slice. ### impl<'a> DecodeValue<'a> for AnyRef<'a> #### fn decode_value(reader: &mut R, header: Header) -> Result, Error> where R: Reader<'a>, Attempt to decode this message using the provided `Reader`. ### impl EncodeValue for AnyRef<'_> #### fn value_len(&self) -> Result Compute the length of this value (sans [`Tag`]+`Length` header) when encoded as ASN.1 DER. #### fn encode_value(&self, writer: &mut impl Writer) -> Result<(), Error> Encode value (sans [`Tag`]+`Length` header) as ASN.1 DER using the provided `Writer`. #### fn header(&self) -> Result where Self: Tagged, Get the `Header` used to encode this value. ### impl<'a> From<&'a Any> for AnyRef<'a> #### fn from(any: &'a Any) -> AnyRef<'a> Converts to this type from the input type. ### impl<'a> From<&'a Ia5String> for AnyRef<'a> #### fn from(international_string: &'a Ia5String) -> AnyRef<'a> Converts to this type from the input type. ### impl<'a> From<&'a ObjectIdentifier> for AnyRef<'a> #### fn from(oid: &'a ObjectIdentifier) -> AnyRef<'a> Converts to this type from the input type. ### impl<'a> From<&'a PrintableString> for AnyRef<'a> #### fn from(printable_string: &'a PrintableString) -> AnyRef<'a> Converts to this type from the input type. ### impl<'a> From<&'a TeletexString> for AnyRef<'a> #### fn from(teletex_string: &'a TeletexString) -> AnyRef<'a> Converts to this type from the input type. ### impl<'a> From<()> for AnyRef<'a> #### fn from(_: ()) -> AnyRef<'a> Converts to this type from the input type. ### impl<'a> From> for AnyRef<'a> #### fn from(internationalized_string: Ia5StringRef<'a>) -> AnyRef<'a> Converts to this type from the input type. ### impl<'a> From for AnyRef<'a> #### fn from(_: Null) -> AnyRef<'a> Converts to this type from the input type. ### impl<'a> From> for AnyRef<'a> #### fn from(octet_string: OctetStringRef<'a>) -> AnyRef<'a> Converts to this type from the input type. ### impl<'a> From> for AnyRef<'a> #### fn from(printable_string: PrintableStringRef<'a>) -> AnyRef<'a> Converts to this type from the input type. ### impl<'a> From> for AnyRef<'a> #### fn from(teletex_string: TeletexStringRef<'a>) -> AnyRef<'a> Converts to this type from the input type. ### impl<'a> From> for AnyRef<'a> #### fn from(utf_string: Utf8StringRef<'a>) -> AnyRef<'a> Converts to this type from the input type. ``` -------------------------------- ### PartialEq for AnyRef<'a> Source: https://docs.rs/gss-api/latest/gss_api/type.SubsequentContextToken.html Provides equality comparison for AnyRef<'a> instances. ```APIDOC ## fn eq(&self, other: &AnyRef<'a>) -> bool Tests for `self` and `other` values to be equal, and is used by `==`. ``` ```APIDOC ## const fn ne(&self, other: &Rhs) -> bool Tests for `!=`. ``` -------------------------------- ### Ownership and Tagging Source: https://docs.rs/gss-api/latest/gss_api/type.SealedMessage.html Explains how to obtain ownership of the data referenced by AnyRef and how to retrieve its ASN.1 tag. ```APIDOC ## impl<'a> RefToOwned<'a> for AnyRef<'a> #### type Owned = Any The resulting type after obtaining ownership. #### fn ref_to_owned(&self) -> as RefToOwned<'a>>::Owned Creates a new object taking ownership of the data. ## impl Tagged for AnyRef<'_> #### fn tag(&self) -> Tag Get the ASN.1 tag that this type is encoded with. ``` -------------------------------- ### Create AnyRef Source: https://docs.rs/gss-api/latest/gss_api/type.SealedMessage.html Constructs a new AnyRef from a given Tag and DER-encoded byte slice. Returns a Result indicating success or failure. ```rust pub fn new(tag: Tag, bytes: &'a [u8]) -> Result, Error> ``` -------------------------------- ### PartialOrd for AnyRef<'a> Source: https://docs.rs/gss-api/latest/gss_api/type.SubsequentContextToken.html Provides partial ordering for AnyRef<'a> instances. ```APIDOC ## fn partial_cmp(&self, other: &AnyRef<'a>) -> Option This method returns an ordering between `self` and `other` values if one exists. ``` ```APIDOC ## fn lt(&self, other: &Rhs) -> bool Tests less than (for `self` and `other`) and is used by the `<` operator. ``` ```APIDOC ## fn le(&self, other: &Rhs) -> bool Tests less than or equal to (for `self` and `other`) and is used by the `<=` operator. ``` ```APIDOC ## fn gt(&self, other: &Rhs) -> bool Tests greater than (for `self` and `other`) and is used by the `>` operator. ``` ```APIDOC ## fn ge(&self, other: &Rhs) -> bool Tests greater than or equal to (for `self` and `other`) and is used by the `>=` operator. ``` -------------------------------- ### AnyRef Implementations for PerMsgToken Source: https://docs.rs/gss-api/latest/gss_api/type.PerMsgToken.html Details the methods available on AnyRef, which are applicable to PerMsgToken. ```APIDOC ## Implementations for AnyRef<'a> ### `impl<'a> AnyRef<'a>` #### `pub const NULL: AnyRef<'a>` `AnyRef` representation of the ASN.1 `NULL` type. #### `pub fn new(tag: Tag, bytes: &'a [u8]) -> Result, Error>` Create a new `AnyRef` from the provided `Tag` and DER bytes. #### `pub fn value(self) -> &'a [u8]` Get the raw value for this `AnyRef` type as a byte slice. #### `pub fn decode_as(self) -> Result where T: Choice<'a> + DecodeValue<'a>` Attempt to decode this `AnyRef` type into the inner value. #### `pub fn is_null(self) -> bool` Is this value an ASN.1 `NULL` value? #### `pub fn sequence(self, f: F) -> Result where F: FnOnce(&mut SliceReader<'a>) -> Result` Attempt to decode this value an ASN.1 `SEQUENCE`, creating a new nested reader and calling the provided argument with it. ``` -------------------------------- ### From> for AnyRef<'a> Source: https://docs.rs/gss-api/latest/gss_api/type.SealedMessage.html Conversion implementation from a PrintableStringRef into an AnyRef. ```rust fn from(printable_string: PrintableStringRef<'a>) -> AnyRef<'a> ``` -------------------------------- ### AnyRef Trait Implementations Source: https://docs.rs/gss-api/latest/gss_api/type.SealedMessage.html Details the various traits implemented for AnyRef, enabling operations like cloning, debugging, encoding, decoding, and conversions from other types. ```APIDOC ## Trait Implementations for AnyRef<'a> ### `impl<'a> Choice<'a> for AnyRef<'a>` #### `fn can_decode(_: Tag) -> bool` Is the provided `Tag` decodable as a variant of this `CHOICE`? ### `impl<'a> Clone for AnyRef<'a>` #### `fn clone(&self) -> AnyRef<'a>` Returns a duplicate of the value. #### `const fn clone_from(&mut self, source: &Self)` Performs copy-assignment from `source`. ### `impl<'a> Debug for AnyRef<'a>` #### `fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>` Formats the value using the given formatter. ### `impl<'a> Decode<'a> for AnyRef<'a>` #### `fn decode(reader: &mut R) -> Result, Error> where R: Reader<'a>` Attempt to decode this message using the provided decoder. #### `fn from_der(bytes: &'a [u8]) -> Result` Parse `Self` from the provided DER-encoded byte slice. ### `impl<'a> DecodeValue<'a> for AnyRef<'a>` #### `fn decode_value(reader: &mut R, header: Header) -> Result, Error> where R: Reader<'a>` Attempt to decode this message using the provided `Reader`. ### `impl EncodeValue for AnyRef<'_>` #### `fn value_len(&self) -> Result` Compute the length of this value (sans [`Tag`]+`Length` header) when encoded as ASN.1 DER. #### `fn encode_value(&self, writer: &mut impl Writer) -> Result<(), Error>` Encode value (sans [`Tag`]+`Length` header) as ASN.1 DER using the provided `Writer`. #### `fn header(&self) -> Result where Self: Tagged` Get the `Header` used to encode this value. ### `impl<'a> From<&'a Any> for AnyRef<'a>` #### `fn from(any: &'a Any) -> AnyRef<'a>` Converts to this type from the input type. ### `impl<'a> From<&'a Ia5String> for AnyRef<'a>` #### `fn from(international_string: &'a Ia5String) -> AnyRef<'a>` Converts to this type from the input type. ### `impl<'a> From<&'a ObjectIdentifier> for AnyRef<'a>` #### `fn from(oid: &'a ObjectIdentifier) -> AnyRef<'a>` Converts to this type from the input type. ### `impl<'a> From<&'a PrintableString> for AnyRef<'a>` #### `fn from(printable_string: &'a PrintableString) -> AnyRef<'a>` Converts to this type from the input type. ### `impl<'a> From<&'a TeletexString> for AnyRef<'a>` #### `fn from(teletex_string: &'a TeletexString) -> AnyRef<'a>` Converts to this type from the input type. ### `impl<'a> From<()> for AnyRef<'a>` #### `fn from(_: ()) -> AnyRef<'a>` Converts to this type from the input type. ### `impl<'a> From> for AnyRef<'a>` #### `fn from(internationalized_string: Ia5StringRef<'a>) -> AnyRef<'a>` Converts to this type from the input type. ### `impl<'a> From for AnyRef<'a>` #### `fn from(_: Null) -> AnyRef<'a>` Converts to this type from the input type. ### `impl<'a> From> for AnyRef<'a>` #### `fn from(octet_string: OctetStringRef<'a>) -> AnyRef<'a>` Converts to this type from the input type. ### `impl<'a> From> for AnyRef<'a>` #### `fn from(printable_string: PrintableStringRef<'a>) -> AnyRef<'a>` Converts to this type from the input type. ### `impl<'a> From> for AnyRef<'a>` #### `fn from(teletex_string: TeletexStringRef<'a>) -> AnyRef<'a>` Converts to this type from the input type. ### `impl<'a> From> for AnyRef<'a>` #### `fn from(utf8_string: Utf8StringRef<'a>) -> AnyRef<'a>` Converts to this type from the input type. ``` -------------------------------- ### Conversion from Any Source: https://docs.rs/gss-api/latest/gss_api/negotiation/type.ContextFlags.html Enables conversion of an `Any` type to a `BitString`. ```APIDOC ## impl<'__der> TryFrom<&'__der Any> for BitString ### Description Provides functionality to attempt conversion from an `Any` reference to a `BitString`. ### Type Alias - `Error`: The type returned in the event of a conversion error. ### Method #### fn try_from(any: &'__der Any) -> Result ### Description Performs the conversion from an `Any` reference to a `BitString`. ### Parameters - `any`: `&'__der Any` - The `Any` reference to convert. ### Returns - `Result` - Ok(`BitString`) on success, or an `Error` on failure. ``` -------------------------------- ### Create Vec from externally allocated memory Source: https://docs.rs/gss-api/latest/gss_api/negotiation/type.MechTypeList.html Shows how to create a `Vec` from memory allocated using `Global.allocate`. This requires careful handling of `Layout` and `AllocError`. The pointer, length, capacity, and allocator must satisfy all safety invariants. ```rust #![feature(allocator_api)] use std::alloc::{AllocError, Allocator, Global, Layout}; fn main() { let layout = Layout::array::(16).expect("overflow cannot happen"); let vec = unsafe { let mem = match Global.allocate(layout) { Ok(mem) => mem.cast::().as_ptr(), Err(AllocError) => return, }; mem.write(1_000_000); Vec::from_raw_parts_in(mem, 1, 16, Global) }; assert_eq!(vec, &[1_000_000]); assert_eq!(vec.capacity(), 16); } ``` -------------------------------- ### Ord for AnyRef<'a> Source: https://docs.rs/gss-api/latest/gss_api/type.SubsequentContextToken.html Provides total ordering for AnyRef<'a> instances. ```APIDOC ## fn cmp(&self, other: &AnyRef<'a>) -> Ordering This method returns an `Ordering` between `self` and `other`. ``` ```APIDOC ## fn max(self, other: Self) -> Self Compares and returns the maximum of two values. ``` ```APIDOC ## fn min(self, other: Self) -> Self Compares and returns the minimum of two values. ``` ```APIDOC ## fn clamp(self, min: Self, max: Self) -> Self Restrict a value to a certain interval. ``` -------------------------------- ### Create Vec with Capacity and Allocator (Nightly) Source: https://docs.rs/gss-api/latest/gss_api/negotiation/type.MechTypeList.html Constructs a Vec with a specified initial capacity using a given allocator. The vector will not reallocate until its capacity is exceeded. This API is experimental and requires the `allocator_api` feature. ```rust #![feature(allocator_api)] use std::alloc::System; let mut vec = Vec::with_capacity_in(10, System); // The vector contains no items, even though it has capacity for more assert_eq!(vec.len(), 0); assert!(vec.capacity() >= 10); // These are all done without reallocating... for i in 0..10 { vec.push(i); } assert_eq!(vec.len(), 10); assert!(vec.capacity() >= 10); // ...but this may make the vector reallocate vec.push(11); assert_eq!(vec.len(), 11); assert!(vec.capacity() >= 11); // A vector of a zero-sized type will always over-allocate, since no // allocation is necessary let vec_units = Vec::<(), System>::with_capacity_in(10, System); assert_eq!(vec_units.capacity(), usize::MAX); ``` -------------------------------- ### Eq Implementation Source: https://docs.rs/gss-api/latest/gss_api/type.PerMsgToken.html Indicates that AnyRef implements the Eq trait. ```APIDOC ## impl<'a> Eq for AnyRef<'a> ``` -------------------------------- ### Convert VideotexStringRef to AnyRef Source: https://docs.rs/gss-api/latest/gss_api/type.PerMsgToken.html Converts a VideotexStringRef into an AnyRef. ```rust fn from(videotex_string: VideotexStringRef<'a>) -> AnyRef<'a> ``` -------------------------------- ### Comparison Methods Source: https://docs.rs/gss-api/latest/gss_api/negotiation/type.ContextFlags.html Provides methods for comparing BitString instances, supporting greater than and greater than or equal to operations. ```APIDOC ## fn gt(&self, other: &Rhs) -> bool ### Description Tests greater than (for `self` and `other`) and is used by the `>` operator. ### Method `gt` ### Parameters - `other`: `&Rhs` - The other value to compare against. ### Returns - `bool` - True if `self` is greater than `other`, false otherwise. ``` ```APIDOC ## fn ge(&self, other: &Rhs) -> bool ### Description 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 against. ### Returns - `bool` - True if `self` is greater than or equal to `other`, false otherwise. ``` -------------------------------- ### From<&'a ObjectIdentifier> for AnyRef<'a> Source: https://docs.rs/gss-api/latest/gss_api/type.SealedMessage.html Conversion implementation from a reference to an ObjectIdentifier into an AnyRef. ```rust fn from(oid: &'a ObjectIdentifier) -> AnyRef<'a> ``` -------------------------------- ### From for AnyRef<'a> Source: https://docs.rs/gss-api/latest/gss_api/type.SealedMessage.html Conversion implementation from a Null type into an AnyRef. ```rust fn from(_: Null) -> AnyRef<'a> ``` -------------------------------- ### From> to Vec Source: https://docs.rs/gss-api/latest/gss_api/negotiation/type.MechTypeList.html Converts a BinaryHeap into a Vec with no data movement or allocation. ```rust impl From> for Vec where A: Allocator, { fn from(heap: BinaryHeap) -> Vec { // ... implementation details ... } } ``` -------------------------------- ### BitString PartialEq Implementation eq Method Source: https://docs.rs/gss-api/latest/gss_api/negotiation/type.ContextFlags.html Implements the `eq` method for testing equality between two BitString values. ```rust fn eq(&self, other: &BitString) -> bool; ``` -------------------------------- ### PartialOrd Implementation Source: https://docs.rs/gss-api/latest/gss_api/type.PerMsgToken.html Provides methods for partial ordering of AnyRef instances. ```APIDOC ## impl<'a> PartialOrd for AnyRef<'a> ### fn partial_cmp(&self, other: &AnyRef<'a>) -> 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. ``` -------------------------------- ### Basic Traits Source: https://docs.rs/gss-api/latest/gss_api/type.SealedMessage.html Lists fundamental traits implemented by AnyRef, such as Copy, Eq, and StructuralPartialEq. ```APIDOC ## impl<'a> Copy for AnyRef<'a> ## impl<'a> Eq for AnyRef<'a> ## impl<'a> StructuralPartialEq for AnyRef<'a> ``` -------------------------------- ### try_reserve_exact Source: https://docs.rs/gss-api/latest/gss_api/negotiation/type.MechTypeList.html Tries to reserve the minimum capacity for at least `additional` elements. Unlike `try_reserve`, it avoids deliberate over-allocation. Returns `Ok(())` if successful, or an error if capacity overflows or the allocator fails. Preserves contents on error. ```APIDOC ## pub fn try_reserve_exact( &mut self, additional: usize, ) -> Result<(), TryReserveError> ### Description Tries to reserve the minimum capacity for at least `additional` elements to be inserted in the given `Vec`. Unlike `try_reserve`, this will not deliberately over-allocate to speculatively avoid frequent allocations. After calling `try_reserve_exact`, capacity will be greater than or equal to `self.len() + additional` if it returns `Ok(())`. Does nothing if the capacity is already sufficient. Note that the allocator may give the collection more space than it requests. Therefore, capacity can not be relied upon to be precisely minimal. Prefer `try_reserve` if future insertions are expected. ### Method `try_reserve_exact` ### Parameters #### Path Parameters - `additional` (usize) - Required - The minimum number of additional elements to reserve capacity for. ### Errors If the capacity overflows, or the allocator reports a failure, then an error is returned. ### Examples ```rust use std::collections::TryReserveError; fn process_data(data: &[u32]) -> Result, TryReserveError> { let mut output = Vec::new(); // Pre-reserve the memory, exiting if we can't output.try_reserve_exact(data.len())?; // Now we know this can't OOM in the middle of our complex work output.extend(data.iter().map(|&val| { val * 2 + 5 // very complicated })); Ok(output) } ``` ``` -------------------------------- ### BitString PartialEq Implementation ne Method Source: https://docs.rs/gss-api/latest/gss_api/negotiation/type.ContextFlags.html Implements the `ne` method for testing inequality between two BitString values. ```rust const fn ne(&self, other: &Rhs) -> bool; ```