### Initialize ServerConfig Builders Source: https://docs.rs/pingora-rustls/0.8.0/pingora_rustls/struct.ServerConfig.html Methods to instantiate a ConfigBuilder for ServerConfig using different levels of configuration control, including process-default, custom providers, and no_std compatible setups. ```rust pub fn builder_with_protocol_versions(versions: &[&'static SupportedProtocolVersion]) -> ConfigBuilder; pub fn builder_with_provider(provider: Arc) -> ConfigBuilder; pub fn builder_with_details(provider: Arc, time_provider: Arc) -> ConfigBuilder; ``` -------------------------------- ### Build ClientConfig with Default Settings Source: https://docs.rs/pingora-rustls/0.8.0/pingora_rustls/struct.ClientConfig.html?search= Creates a builder for a client configuration using the process-default `CryptoProvider` and safe protocol version defaults. This is a convenient starting point for most client configurations. Refer to `ConfigBuilder` documentation for more details. ```rust pub fn builder() -> ConfigBuilder ``` -------------------------------- ### Basic Type Conversion in Rust Source: https://docs.rs/pingora-rustls/0.8.0/pingora_rustls/struct.CertificateDer.html?search=std%3A%3Avec Provides examples of basic type conversions using `from` and `into`. The `from` method takes a value and returns it unchanged, while `into` calls the corresponding `From` implementation to perform the conversion. ```rust fn from(t: T) -> T fn into(self) -> U ``` -------------------------------- ### Initialize WebPkiServerVerifier Source: https://docs.rs/pingora-rustls/0.8.0/pingora_rustls/struct.WebPkiServerVerifier.html?search=std%3A%3Avec Demonstrates how to instantiate a builder for the WebPkiServerVerifier using either the default crypto provider or a custom one. ```rust pub fn builder(roots: Arc) -> ServerCertVerifierBuilder; pub fn builder_with_provider(roots: Arc, provider: Arc) -> ServerCertVerifierBuilder; ``` -------------------------------- ### Getting the Length of a Byte Slice in Rust Source: https://docs.rs/pingora-rustls/0.8.0/pingora_rustls/struct.CertificateDer.html?search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E Returns the number of elements (bytes) in a slice. This is a fundamental operation for understanding the size of the data. The example shows getting the length of an array. ```rust pub fn len(&self) -> usize // Examples: let a = [1, 2, 3]; assert_eq!(a.len(), 3); ``` -------------------------------- ### Create ServerName Instances Source: https://docs.rs/pingora-rustls/0.8.0/pingora_rustls/enum.ServerName.html?search= Demonstrates how to instantiate a ServerName from string slices or owned Strings using TryFrom and TryInto traits. ```rust // From &str ServerName::try_from("example.com").expect("invalid DNS name"); // From owned String let name = "example.com".to_string(); ServerName::try_from(name).expect("invalid DNS name"); // Using try_into let x: ServerName = "example.com".try_into().expect("invalid DNS name"); ``` -------------------------------- ### Get Element Index from Reference in Rust Slice Source: https://docs.rs/pingora-rustls/0.8.0/pingora_rustls/struct.CertificateDer.html Returns the index of an element reference within a slice. Returns None if the reference does not point to the start of an element. Uses pointer arithmetic and does not compare elements. ```rust let nums: &[u32] = &[1, 7, 1, 1]; let num = &nums[2]; assert_eq!(num, &1); assert_eq!(nums.element_offset(num), Some(2)); let arr: &[[u32; 2]] = &[[0, 1], [2, 3]]; let flat_arr: &[u32] = arr.as_flattened(); let ok_elm: &[u32; 2] = flat_arr[0..2].try_into().unwrap(); let weird_elm: &[u32; 2] = flat_arr[1..3].try_into().unwrap(); assert_eq!(ok_elm, &[0, 1]); assert_eq!(weird_elm, &[1, 2]); assert_eq!(arr.element_offset(ok_elm), Some(0)); // Points to element 0 assert_eq!(arr.element_offset(weird_elm), None); // Points between element 0 and 1 ``` -------------------------------- ### Get Element Offset in Rust Slice Source: https://docs.rs/pingora-rustls/0.8.0/pingora_rustls/struct.CertificateDer.html?search=u32+-%3E+bool Returns the index of an element reference within a slice. Returns None if the element reference does not point to the start of an element. This method uses pointer arithmetic and does not compare elements. Panics if T is zero-sized. ```rust let nums: &[u32] = &[1, 7, 1, 1]; let num = &nums[2]; assert_eq!(num, &1); assert_eq!(nums.element_offset(num), Some(2)); ``` ```rust let arr: &[[u32; 2]] = &[[0, 1], [2, 3]]; let flat_arr: &[u32] = arr.as_flattened(); let ok_elm: &[u32; 2] = flat_arr[0..2].try_into().unwrap(); let weird_elm: &[u32; 2] = flat_arr[1..3].try_into().unwrap(); assert_eq!(ok_elm, &[0, 1]); assert_eq!(weird_elm, &[1, 2]); assert_eq!(arr.element_offset(ok_elm), Some(0)); // Points to element 0 assert_eq!(arr.element_offset(weird_elm), None); // Points between element 0 and 1 ``` -------------------------------- ### Initialize ClientConfig with Builders Source: https://docs.rs/pingora-rustls/0.8.0/pingora_rustls/struct.ClientConfig.html?search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E Demonstrates the various builder methods available for creating a 'ClientConfig' instance, allowing for customization of crypto providers and protocol versions. ```rust use rustls::ClientConfig; use std::sync::Arc; // Default builder let builder = ClientConfig::builder(); // Builder with specific protocol versions let versions = &[&rustls::version::TLS13]; let builder_versions = ClientConfig::builder_with_protocol_versions(versions); // Builder with custom CryptoProvider let provider = Arc::new(rustls::crypto::ring::default_provider()); let builder_provider = ClientConfig::builder_with_provider(provider); ``` -------------------------------- ### Initialize ClientConfig using Builder Pattern Source: https://docs.rs/pingora-rustls/0.8.0/pingora_rustls/struct.ClientConfig.html?search=std%3A%3Avec Demonstrates how to instantiate a ClientConfig using the builder pattern, allowing for the selection of specific cryptographic providers and protocol versions. ```rust use std::sync::Arc; use rustls::{ClientConfig, CryptoProvider}; // Create a builder with default provider let builder = ClientConfig::builder(); // Create a builder with a specific provider let provider = Arc::new(CryptoProvider::default()); let builder_with_provider = ClientConfig::builder_with_provider(provider); // Create a builder with specific protocol versions let versions = &[&rustls::version::TLS13]; let builder_with_versions = ClientConfig::builder_with_protocol_versions(versions); ``` -------------------------------- ### Get Current UnixTime in Rust Source: https://docs.rs/pingora-rustls/0.8.0/pingora_rustls/struct.UnixTime.html?search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E Provides a function to get the current time as a UnixTime object. This is a common utility for time tracking. ```rust pub fn now() -> UnixTime ``` -------------------------------- ### Initialize ClientConfig using the builder pattern Source: https://docs.rs/pingora-rustls/0.8.0/pingora_rustls/struct.ClientConfig.html Demonstrates the various ways to instantiate a ClientConfig using the builder pattern, allowing for default or custom cryptographic providers and protocol versions. ```rust use rustls::ClientConfig; use std::sync::Arc; // Create a builder with default provider and versions let builder = ClientConfig::builder(); // Create a builder with specific protocol versions let builder_versions = ClientConfig::builder_with_protocol_versions(&[&rustls::version::TLS13]); // Create a builder with a specific CryptoProvider let provider = Arc::new(rustls::crypto::ring::default_provider()); let builder_provider = ClientConfig::builder_with_provider(provider); ``` -------------------------------- ### GET /slice/last Source: https://docs.rs/pingora-rustls/0.8.0/pingora_rustls/struct.CertificateDer.html?search=u32+-%3E+bool Retrieves the last element of the slice. ```APIDOC ## GET /slice/last ### Description Returns the last element of the slice, or `None` if the slice is empty. ### Method GET ### Endpoint /slice/last ### Response #### Success Response (200) - **element** (Option<&T>) - The last element of the slice. #### Response Example { "result": 30 } ``` -------------------------------- ### GET /slice/as_ptr Source: https://docs.rs/pingora-rustls/0.8.0/pingora_rustls/struct.CertificateDer.html?search=u32+-%3E+bool Retrieves a raw pointer to the slice buffer. ```APIDOC ## GET /slice/as_ptr ### Description Returns a raw pointer to the slice’s buffer. Note: The caller must ensure the slice outlives the pointer. ### Method GET ### Endpoint /slice/as_ptr ### Response #### Success Response (200) - **pointer** (*const T) - Raw pointer to the start of the slice. #### Response Example { "pointer": "0x7ff7bfeff120" } ``` -------------------------------- ### Initialize KeyLogFile in Rust Source: https://docs.rs/pingora-rustls/0.8.0/pingora_rustls/struct.KeyLogFile.html?search= Demonstrates the definition and instantiation of the KeyLogFile struct. The new() method automatically checks for the SSLKEYLOGFILE environment variable and attempts to open the target file. ```rust pub struct KeyLogFile(/* private fields */); impl KeyLogFile { pub fn new() -> KeyLogFile { // Implementation details: inspects SSLKEYLOGFILE and opens the file } } ``` -------------------------------- ### GET /slice/get Source: https://docs.rs/pingora-rustls/0.8.0/pingora_rustls/struct.CertificateDer.html?search=u32+-%3E+bool Safely retrieves an element or sub-slice by index. ```APIDOC ## GET /slice/get ### Description Returns a reference to an element at a specific position or a sub-slice based on a range index. ### Method GET ### Endpoint /slice/get ### Parameters #### Query Parameters - **index** (SliceIndex) - Required - The position or range to retrieve. ### Response #### Success Response (200) - **value** (Option<&Output>) - The requested element or sub-slice. #### Response Example { "result": 40 } ``` -------------------------------- ### Initialize ServerConfig Builder Source: https://docs.rs/pingora-rustls/0.8.0/pingora_rustls/struct.ServerConfig.html?search=std%3A%3Avec Demonstrates how to initiate the creation of a server configuration using the builder pattern. This method uses default cryptographic providers and protocol settings. ```rust use pingora_rustls::ServerConfig; // Create a builder for a server configuration with default settings let builder = ServerConfig::builder(); ``` -------------------------------- ### GET /slice/first_chunk Source: https://docs.rs/pingora-rustls/0.8.0/pingora_rustls/struct.CertificateDer.html?search=u32+-%3E+bool Retrieves the first N elements as an array reference. ```APIDOC ## GET /slice/first_chunk ### Description Returns an array reference to the first `N` items in the slice. Returns `None` if the slice length is less than `N`. ### Method GET ### Endpoint /slice/first_chunk ### Parameters #### Query Parameters - **N** (usize) - Required - The number of elements to retrieve. ### Response #### Success Response (200) - **chunk** (Option<&[T; N]>) - Reference to the first N items. #### Response Example { "result": [10, 40] } ``` -------------------------------- ### Create KeyLogFile Instance in Rust Source: https://docs.rs/pingora-rustls/0.8.0/pingora_rustls/struct.KeyLogFile.html?search=u32+-%3E+bool Constructs a new KeyLogFile instance. This function initializes the KeyLogFile by inspecting the SSLKEYLOGFILE environment variable and attempting to open the specified file for writing keys. ```rust pub fn new() -> KeyLogFile ``` -------------------------------- ### GET /supported_verify_schemes Source: https://docs.rs/pingora-rustls/0.8.0/pingora_rustls/struct.WebPkiClientVerifier.html Retrieves the list of supported signature schemes for TLS verification. ```APIDOC ## GET /supported_verify_schemes ### Description Returns the list of SignatureSchemes that this verifier will handle in verify_tls12_signature and verify_tls13_signature calls. ### Method GET ### Endpoint /supported_verify_schemes ### Response #### Success Response (200) - **schemes** (Vec) - A list of supported signature schemes. #### Response Example { "schemes": ["RSA_PKCS1_SHA256", "ECDSA_NISTP256_SHA256"] } ``` -------------------------------- ### ClientConfig Builder Initialization Source: https://docs.rs/pingora-rustls/0.8.0/pingora_rustls/struct.ClientConfig.html?search=u32+-%3E+bool Provides methods to create a builder for `ClientConfig`. These builders allow for flexible configuration of client settings, including protocol versions and cryptographic providers. The `builder()` function uses default settings, while `builder_with_protocol_versions` and `builder_with_provider` offer more control over specific aspects. ```rust pub fn builder() -> ConfigBuilder Create a builder for a client configuration with the process-default `CryptoProvider` and safe protocol version defaults. For more information, see the `ConfigBuilder` documentation. Source ``` ```rust pub fn builder_with_protocol_versions( versions: &[&'static SupportedProtocolVersion], ) -> ConfigBuilder Create a builder for a client configuration with the process-default `CryptoProvider` and the provided protocol versions. Panics if * the supported versions are not compatible with the provider (eg. the combination of ciphersuites supported by the provider and supported versions lead to zero cipher suites being usable), * if a `CryptoProvider` cannot be resolved using a combination of the crate features and process default. For more information, see the `ConfigBuilder` documentation. Source ``` ```rust pub fn builder_with_provider( provider: Arc, ) -> ConfigBuilder Create a builder for a client configuration with a specific `CryptoProvider`. This will use the provider’s configured ciphersuites. You must additionally choose which protocol versions to enable, using `with_protocol_versions` or `with_safe_default_protocol_versions` and handling the `Result` in case a protocol version is not supported by the provider’s ciphersuites. For more information, see the `ConfigBuilder` documentation. Source ``` -------------------------------- ### POST /slice/trim_prefix Source: https://docs.rs/pingora-rustls/0.8.0/pingora_rustls/struct.CertificateDer.html?search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E Removes an optional prefix from a slice if it matches the start. ```APIDOC ## POST /slice/trim_prefix ### Description Returns a subslice with the optional prefix removed. If the prefix is absent, the original slice is returned. ### Method POST ### Parameters #### Request Body - **prefix** (SlicePattern) - Required - The pattern to remove from the start. ### Response #### Success Response (200) - **result** ([T]) - The trimmed slice or original slice. ### Response Example { "result": [40, 30] } ``` -------------------------------- ### Initialize and use KeyLogFile in Rust Source: https://docs.rs/pingora-rustls/0.8.0/pingora_rustls/struct.KeyLogFile.html?search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E Demonstrates the instantiation of the KeyLogFile struct and its role in logging SSL secrets. The implementation automatically checks the SSLKEYLOGFILE environment variable upon creation. ```rust use pingora_rustls::KeyLogFile; // Initialize the logger let logger = KeyLogFile::new(); // The logger will now write to the file specified by SSLKEYLOGFILE // when used with a TLS stack that supports the KeyLog trait. ``` -------------------------------- ### Initialize and Use TlsAcceptor in Rust Source: https://docs.rs/pingora-rustls/0.8.0/pingora_rustls/struct.TlsAcceptor.html Demonstrates the structure of TlsAcceptor and its primary methods for accepting TLS connections. The accept methods require an IO stream that implements AsyncRead and AsyncWrite. ```rust pub struct TlsAcceptor { /* private fields */ } impl TlsAcceptor { pub fn accept(&self, stream: IO) -> Accept where IO: AsyncRead + AsyncWrite + Unpin; pub fn accept_with(&self, stream: IO, f: F) -> Accept where IO: AsyncRead + AsyncWrite + Unpin, F: FnOnce(&mut ServerConnection); pub fn config(&self) -> &Arc; } ``` -------------------------------- ### GET /slice/binary_search Source: https://docs.rs/pingora-rustls/0.8.0/pingora_rustls/struct.CertificateDer.html?search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E Performs a binary search on a sorted slice to locate an element. ```APIDOC ## GET /slice/binary_search ### Description Binary searches this slice for a given element. Returns Ok(index) if found, or Err(index) where it could be inserted. ### Method GET ### Parameters #### Query Parameters - **x** (T) - Required - The element to search for. ### Response #### Success Response (200) - **result** (Result) - The index of the element or the insertion point. ### Response Example { "result": {"Ok": 2} } ``` -------------------------------- ### Create WebPkiServerVerifier Builder (Rust) Source: https://docs.rs/pingora-rustls/0.8.0/pingora_rustls/struct.WebPkiServerVerifier.html Provides methods to create a builder for configuring the WebPkiServerVerifier. This allows customization of the certificate verification process using default or specified CryptoProviders and RootCertStores. ```rust pub fn builder(roots: Arc) -> ServerCertVerifierBuilder pub fn builder_with_provider( roots: Arc, provider: Arc, ) -> ServerCertVerifierBuilder ``` -------------------------------- ### Get Crypto Provider Source: https://docs.rs/pingora-rustls/0.8.0/pingora_rustls/struct.ServerConfig.html?search=std%3A%3Avec Retrieves the CryptoProvider used to construct the server configuration. ```APIDOC ## GET /websites/rs_pingora-rustls_0_8_0_pingora_rustls/crypto_provider ### Description Returns the crypto provider used to construct this server configuration. ### Method GET ### Endpoint /websites/rs_pingora-rustls_0_8_0_pingora_rustls/crypto_provider ### Response #### Success Response (200) - **crypto_provider** (Arc) - The crypto provider instance. #### Response Example ```json { "crypto_provider": "" } ``` ``` -------------------------------- ### Create an Empty RootCertStore Source: https://docs.rs/pingora-rustls/0.8.0/pingora_rustls/struct.RootCertStore.html Provides a constructor function 'empty' to create a new, empty RootCertStore. This is useful for initializing a certificate store that will be populated later. ```rust pub fn empty() -> RootCertStore ``` -------------------------------- ### Get Length of CertificateDer Slice in Rust Source: https://docs.rs/pingora-rustls/0.8.0/pingora_rustls/struct.CertificateDer.html?search= Returns the number of bytes in the `CertificateDer` slice. ```rust pub fn len(&self) -> usize // Example: // let a = [1, 2, 3]; // assert_eq!(a.len(), 3); ``` -------------------------------- ### Initialize and use KeyLogFile in Rust Source: https://docs.rs/pingora-rustls/0.8.0/pingora_rustls/struct.KeyLogFile.html Demonstrates how to instantiate the KeyLogFile struct and utilize its implementation of the KeyLog trait to log TLS secrets. ```rust use pingora_rustls::KeyLogFile; // Initialize the KeyLogFile let key_logger = KeyLogFile::new(); // Example of manual logging if implementing custom logic // key_logger.log("CLIENT_HANDSHAKE_TRAFFIC_SECRET", client_random, secret); ``` -------------------------------- ### GET /WebPkiClientVerifier/requires_raw_public_keys Source: https://docs.rs/pingora-rustls/0.8.0/pingora_rustls/struct.WebPkiClientVerifier.html?search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E Checks if the verifier requires raw public keys as defined in RFC 7250. ```APIDOC ## GET /WebPkiClientVerifier/requires_raw_public_keys ### Description Returns a boolean indicating whether this verifier requires raw public keys as defined in RFC 7250. ### Method GET ### Endpoint /WebPkiClientVerifier/requires_raw_public_keys ### Response #### Success Response (200) - **requires_raw** (bool) - True if raw public keys are required, false otherwise. #### Response Example { "requires_raw": false } ``` -------------------------------- ### GET /WebPkiClientVerifier/supported_verify_schemes Source: https://docs.rs/pingora-rustls/0.8.0/pingora_rustls/struct.WebPkiClientVerifier.html?search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E Retrieves the list of signature schemes supported by the verifier for TLS 1.2 and 1.3. ```APIDOC ## GET /WebPkiClientVerifier/supported_verify_schemes ### Description Returns the list of SignatureSchemes that this verifier will handle in verify_tls12_signature and verify_tls13_signature calls. ### Method GET ### Endpoint /WebPkiClientVerifier/supported_verify_schemes ### Response #### Success Response (200) - **schemes** (Vec) - A list of supported signature schemes. #### Response Example { "schemes": ["RSA_PKCS1_SHA256", "ECDSA_NISTP256_SHA256"] } ``` -------------------------------- ### ClientConfig Builder Methods Source: https://docs.rs/pingora-rustls/0.8.0/pingora_rustls/struct.ClientConfig.html This section covers the builder methods available for creating and configuring `ClientConfig` instances. ```APIDOC ## ClientConfig Builder Methods ### `builder() -> ConfigBuilder` Creates a builder for a client configuration with process-default `CryptoProvider` and safe protocol version defaults. ### `builder_with_protocol_versions(versions: &[&'static SupportedProtocolVersion]) -> ConfigBuilder` Creates a builder for a client configuration with process-default `CryptoProvider` and specified protocol versions. Panics if versions are incompatible with the provider or if a `CryptoProvider` cannot be resolved. ### `builder_with_provider(provider: Arc) -> ConfigBuilder` Creates a builder for a client configuration with a specific `CryptoProvider`. Requires explicit selection of protocol versions using `with_protocol_versions` or `with_safe_default_protocol_versions`. ``` -------------------------------- ### GET /requires_raw_public_keys Source: https://docs.rs/pingora-rustls/0.8.0/pingora_rustls/struct.WebPkiClientVerifier.html Checks if the verifier requires raw public keys as defined in RFC 7250. ```APIDOC ## GET /requires_raw_public_keys ### Description Returns a boolean indicating whether this verifier requires raw public keys as defined in RFC 7250. ### Method GET ### Endpoint /requires_raw_public_keys ### Response #### Success Response (200) - **requires_raw** (bool) - True if raw public keys are required, false otherwise. #### Response Example { "requires_raw": false } ``` -------------------------------- ### Create ClientConfig Builder Source: https://docs.rs/pingora-rustls/0.8.0/pingora_rustls/struct.ClientConfig.html?search= Initializes a builder for ClientConfig without default implementation details. This is specifically designed for no_std environments and requires explicit TimeProvider and CryptoProvider instances. ```rust pub fn builder_with_details( provider: Arc, time_provider: Arc, ) -> ConfigBuilder ``` -------------------------------- ### GET /load_pem_file_ca Source: https://docs.rs/pingora-rustls/0.8.0/pingora_rustls/fn.load_pem_file_ca.html Loads a PEM-formatted certificate authority file from the specified filesystem path. ```APIDOC ## GET load_pem_file_ca ### Description Loads a PEM-encoded certificate authority file from a given file path and returns the raw bytes. ### Method GET (Internal Function) ### Endpoint load_pem_file_ca(path: &String) ### Parameters #### Path Parameters - **path** (String) - Required - The filesystem path to the PEM file. ### Request Example { "path": "/etc/ssl/certs/ca-certificates.crt" } ### Response #### Success Response (200) - **data** (Vec) - The raw byte content of the loaded PEM file. #### Response Example { "data": [45, 45, 45, 45, 45, 66, 69, 71, 73, 78, ...] } ``` -------------------------------- ### Slice Iterator Source: https://docs.rs/pingora-rustls/0.8.0/pingora_rustls/struct.CertificateDer.html?search= Returns an iterator over the elements of the slice, yielding items from start to end. ```APIDOC ## GET /iter ### Description Returns an iterator over the slice. The iterator yields all items from start to end. ### Method GET ### Endpoint /iter ### Parameters None ### Request Example None ### Response #### Success Response (200) - **iterator** (*Iter<'_, T>*) - An iterator yielding elements of the slice. #### Response Example ```json { "iterator": [ 1, 2, 4 ] } ``` ``` -------------------------------- ### Create ServerConfig Builder with Protocol Versions (Rust) Source: https://docs.rs/pingora-rustls/0.8.0/pingora_rustls/struct.ServerConfig.html?search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E Initializes a server configuration builder with a specific set of supported protocol versions and the process-default CryptoProvider. This method may panic if the provided versions are incompatible with the provider, leading to no usable cipher suites, or if a CryptoProvider cannot be resolved. ```rust pub fn builder_with_protocol_versions( versions: &['static SupportedProtocolVersion], ) -> ConfigBuilder ``` -------------------------------- ### as_rchunks Source: https://docs.rs/pingora-rustls/0.8.0/pingora_rustls/struct.CertificateDer.html?search=std%3A%3Avec Splits a slice into N-element arrays starting from the end, returning the remainder and the chunks. ```APIDOC ## [METHOD] as_rchunks ### Description Splits the slice into a slice of `N`-element arrays, starting at the end of the slice, and a remainder slice with length strictly less than `N`. ### Panics Panics if `N` is zero. ### Request Example ```rust let slice = ['l', 'o', 'r', 'e', 'm']; let (remainder, chunks) = slice.as_rchunks::<2>(); ``` ### Response - **Returns** (&[T], &[[T; N]]) - A tuple containing the remainder and the chunks. ``` -------------------------------- ### as_chunks Source: https://docs.rs/pingora-rustls/0.8.0/pingora_rustls/struct.CertificateDer.html?search=std%3A%3Avec Splits a slice into N-element arrays starting from the beginning, returning the chunks and the remainder. ```APIDOC ## [METHOD] as_chunks ### Description Splits the slice into a slice of `N`-element arrays, starting at the beginning of the slice, and a remainder slice with length strictly less than `N`. ### Panics Panics if `N` is zero. ### Request Example ```rust let slice = ['l', 'o', 'r', 'e', 'm']; let (chunks, remainder) = slice.as_chunks::<2>(); ``` ### Response - **Returns** (&[[T; N]], &[T]) - A tuple containing the chunks and the remaining elements. ``` -------------------------------- ### ClientConfig Builder Methods Source: https://docs.rs/pingora-rustls/0.8.0/pingora_rustls/struct.ClientConfig.html?search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E Provides methods to create and configure a ClientConfig using a builder pattern. These methods allow customization of protocol versions, crypto providers, and other client-specific settings. ```APIDOC ## ClientConfig Builder Methods ### Description Methods for creating and configuring `ClientConfig` instances using a builder pattern. These facilitate the customization of various client-side TLS settings. ### Method `pub fn builder() -> ConfigBuilder` ### Description Creates a builder for a client configuration with process-default `CryptoProvider` and safe protocol version defaults. ### Method `pub fn builder_with_protocol_versions(versions: &[&'static SupportedProtocolVersion]) -> ConfigBuilder` ### Description Creates a builder for a client configuration with process-default `CryptoProvider` and the provided protocol versions. ### Panics - If the supported versions are not compatible with the provider (e.g., the combination of ciphersuites supported by the provider and supported versions lead to zero cipher suites being usable). - If a `CryptoProvider` cannot be resolved using a combination of the crate features and process default. ### Method `pub fn builder_with_provider(provider: Arc) -> ConfigBuilder` ### Description Creates a builder for a client configuration with a specific `CryptoProvider`. ### Usage This will use the provider’s configured ciphersuites. You must additionally choose which protocol versions to enable, using `with_protocol_versions` or `with_safe_default_protocol_versions` and handling the `Result` in case a protocol version is not supported by the provider’s ciphersuites. ### Note For more information on `ConfigBuilder`, refer to its documentation. ``` -------------------------------- ### Configure WebPkiClientVerifier for Rustls Source: https://docs.rs/pingora-rustls/0.8.0/pingora_rustls/struct.WebPkiClientVerifier.html?search=std%3A%3Avec Demonstrates various ways to instantiate a WebPkiClientVerifier, including requiring certificates, allowing unauthenticated access, disabling authentication, and enabling CRL checks. ```rust // Require client certificate let client_verifier = WebPkiClientVerifier::builder(roots.into()) .build() .unwrap(); // Allow optional client certificate let client_verifier = WebPkiClientVerifier::builder(roots.into()) .allow_unauthenticated() .build() .unwrap(); // Disable client authentication let client_verifier = WebPkiClientVerifier::no_client_auth(); // Configure with CRLs let client_verifier = WebPkiClientVerifier::builder(roots.into()) .with_crls(crls) .build() .unwrap(); ``` -------------------------------- ### Iterate over slice elements in Rust Source: https://docs.rs/pingora-rustls/0.8.0/pingora_rustls/struct.CertificateDer.html?search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E Returns an iterator that yields references to all items in the slice from start to end. ```rust let x = &[1, 2, 4]; let mut iterator = x.iter(); assert_eq!(iterator.next(), Some(&1)); assert_eq!(iterator.next(), Some(&2)); assert_eq!(iterator.next(), Some(&4)); assert_eq!(iterator.next(), None); ``` -------------------------------- ### rsplit Source: https://docs.rs/pingora-rustls/0.8.0/pingora_rustls/struct.CertificateDer.html?search= Returns an iterator over subslices separated by elements that match a predicate, starting from the end of the slice and working backwards. ```APIDOC ## POST /websites/rs_pingora-rustls_0_8_0_pingora_rustls/rsplit ### Description Returns an iterator over subslices separated by elements that match a given predicate, processing the slice from right to left. The matched elements are not included in the subslices. ### Method POST ### Endpoint /websites/rs_pingora-rustls_0_8_0_pingora_rustls/rsplit ### Parameters #### Query Parameters - **pred** (FnMut(&T) -> bool) - Required - A closure that returns true for elements that should act as separators. ### Request Body ```json { "slice": ["T"], "pred": "closure_definition" } ``` ### Response #### Success Response (200) - **iterator** (RSplit<'_, T, F>) - An iterator yielding subslices from right to left. #### Response Example ```json { "iterator": [ [44, 55], [11, 22, 33] ] } ``` ``` -------------------------------- ### Create WebPkiServerVerifier Builder with Default CryptoProvider (Rust) Source: https://docs.rs/pingora-rustls/0.8.0/pingora_rustls/struct.WebPkiServerVerifier.html?search= Creates a builder for configuring the webpki server certificate verifier using the process-default CryptoProvider. Server certificates are verified against the provided RootCertStore. ```rust pub fn builder(roots: Arc) -> ServerCertVerifierBuilder ``` -------------------------------- ### as_array Source: https://docs.rs/pingora-rustls/0.8.0/pingora_rustls/struct.CertificateDer.html?search=u32+-%3E+bool Gets a reference to the underlying array. Returns None if the specified size N does not match the slice's length. ```APIDOC ## GET /websites/rs_pingora-rustls_0_8_0_pingora_rustls/as_array ### Description Gets a reference to the underlying array. If `N` is not exactly equal to the length of `self`, then this method returns `None`. ### Method GET ### Endpoint /websites/rs_pingora-rustls_0_8_0_pingora_rustls/as_array ### Parameters #### Query Parameters - **self** (&[T; N]) - Required - The slice to attempt to get as an array. - **N** (usize) - Required - The desired size of the array. ### Response #### Success Response (200) - **Option<&[T; N]>** (Option<&[T; N]>) - An Option containing a reference to the array if the size matches, otherwise None. #### Response Example ```json { "example": "Some([1, 2, 3])" } ``` ``` -------------------------------- ### Create ServerName from String (with alloc feature) Source: https://docs.rs/pingora-rustls/0.8.0/pingora_rustls/enum.ServerName.html?search=u32+-%3E+bool Shows how to create an owned ServerName instance from a String. This requires the `alloc` feature to be enabled. It also uses `TryFrom` and panics if the string is not a valid DNS name. ```rust let name = "example.com".to_string(); #[cfg(feature = "alloc")] ServerName::try_from(name).expect("invalid DNS name"); ``` -------------------------------- ### Manage certificates in RootCertStore Source: https://docs.rs/pingora-rustls/0.8.0/pingora_rustls/struct.RootCertStore.html?search=std%3A%3Avec Methods to interact with the certificate store, including creating an empty store, adding certificates, and querying store status. ```rust impl RootCertStore { pub fn empty() -> RootCertStore { ... } pub fn add_parsable_certificates<'a>(&mut self, der_certs: impl IntoIterator>) -> (usize, usize) { ... } pub fn add(&mut self, der: CertificateDer<'_>) -> Result<(), Error> { ... } pub fn subjects(&self) -> Vec { ... } pub fn is_empty(&self) -> bool { ... } pub fn len(&self) -> usize { ... } } ``` -------------------------------- ### Implement Any for T in Rust (Blanket) Source: https://docs.rs/pingora-rustls/0.8.0/pingora_rustls/struct.Ellipses.html This snippet shows a blanket implementation of the Any trait for any type T in Rust. It provides a method to get the TypeId of the instance. ```rust use std::any::TypeId; impl Any for T { fn type_id(&self) -> TypeId { // Gets the `TypeId` of `self`. TypeId::of::() } } ``` -------------------------------- ### Check slice prefixes and suffixes Source: https://docs.rs/pingora-rustls/0.8.0/pingora_rustls/struct.CertificateDer.html?search=std%3A%3Avec Verifies if a slice starts or ends with a specific sequence using starts_with and ends_with methods. ```rust let v = [10, 40, 30]; assert!(v.starts_with(&[10, 40])); assert!(v.ends_with(&[40, 30])); ``` -------------------------------- ### POST /builder Source: https://docs.rs/pingora-rustls/0.8.0/pingora_rustls/struct.WebPkiServerVerifier.html?search=u32+-%3E+bool Creates a builder for the webpki server certificate verifier configuration using the process-default CryptoProvider. ```APIDOC ## POST /builder ### Description Creates a builder for the `webpki` server certificate verifier configuration using the process-default `CryptoProvider`. Server certificates will be verified using the trust anchors found in the provided `roots`. ### Method POST ### Endpoint /builder ### Parameters #### Request Body - **roots** (Arc) - Required - The trust anchors used for certificate verification. ### Request Example { "roots": "" } ### Response #### Success Response (200) - **builder** (ServerCertVerifierBuilder) - A configured builder instance. #### Response Example { "builder": "ServerCertVerifierBuilder" } ``` -------------------------------- ### Create ServerConfig Builder with Custom Details (Rust) Source: https://docs.rs/pingora-rustls/0.8.0/pingora_rustls/struct.ServerConfig.html?search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E Initializes a server configuration builder for `no_std` environments, requiring explicit `CryptoProvider` and `TimeProvider`. This builder uses the provided provider's cipher suites and necessitates the selection of protocol versions via `with_protocol_versions` or `with_safe_default_protocol_versions`, including error handling for unsupported versions. ```rust pub fn builder_with_details( provider: Arc, time_provider: Arc, ) -> ConfigBuilder ``` -------------------------------- ### rsplit Source: https://docs.rs/pingora-rustls/0.8.0/pingora_rustls/struct.CertificateDer.html Returns an iterator over subslices separated by elements that match a predicate, starting from the end of the slice. The matched element is not included. ```APIDOC ## POST /websites/rs_pingora-rustls_0_8_0_pingora_rustls/rsplit ### Description Returns an iterator over subslices separated by elements that match `pred`, starting at the end of the slice and working backwards. The matched element is not contained in the subslices. ### Method POST ### Endpoint /websites/rs_pingora-rustls_0_8_0_pingora_rustls/rsplit ### Parameters #### Request Body - **slice** (array) - Required - The slice to be split. - **pred** (function) - Required - A closure that returns true for elements that should act as separators. ### Request Example ```json { "slice": [11, 22, 33, 0, 44, 55], "pred": "num => *num == 0" } ``` ### Response #### Success Response (200) - **iterator** (iterator) - An iterator yielding subslices. #### Response Example ```json { "iterator": [ [44, 55], [11, 22, 33] ] } ``` ``` -------------------------------- ### Accept TLS connections Source: https://docs.rs/pingora-rustls/0.8.0/pingora_rustls/struct.TlsAcceptor.html?search=std%3A%3Avec Methods to initiate a TLS handshake on an asynchronous stream. accept_with allows for custom configuration of the server connection during the handshake process. ```rust pub fn accept(&self, stream: IO) -> Accept where IO: AsyncRead + AsyncWrite + Unpin; pub fn accept_with(&self, stream: IO, f: F) -> Accept where IO: AsyncRead + AsyncWrite + Unpin, F: FnOnce(&mut ServerConnection); ``` -------------------------------- ### Get the Number of Certificates in Store Source: https://docs.rs/pingora-rustls/0.8.0/pingora_rustls/struct.RootCertStore.html Returns the total number of certificates currently stored in the RootCertStore. This provides a count of the trusted roots. ```rust pub fn len(&self) -> usize ``` -------------------------------- ### Get ServerName as String Source: https://docs.rs/pingora-rustls/0.8.0/pingora_rustls/enum.ServerName.html Returns the string representation of a ServerName. For DnsName, it returns a borrowed str, while for IpAddress, it returns an allocated String. ```rust pub fn to_str(&self) -> Cow<'_, str> ``` -------------------------------- ### Manage certificates in RootCertStore Source: https://docs.rs/pingora-rustls/0.8.0/pingora_rustls/struct.RootCertStore.html?search=u32+-%3E+bool Methods to initialize an empty store, add certificates, and query store status. These methods handle DER-encoded certificates and provide diagnostics for parsing failures. ```rust impl RootCertStore { pub fn empty() -> RootCertStore { ... } pub fn add_parsable_certificates<'a>(&mut self, der_certs: impl IntoIterator>) -> (usize, usize) { ... } pub fn add(&mut self, der: CertificateDer<'_>) -> Result<(), Error> { ... } pub fn is_empty(&self) -> bool { ... } pub fn len(&self) -> usize { ... } } ``` -------------------------------- ### Get Seconds from UnixTime in Rust Source: https://docs.rs/pingora-rustls/0.8.0/pingora_rustls/struct.UnixTime.html?search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E Retrieves the number of seconds since the Unix epoch from a UnixTime object. This method returns a u64 value. ```rust pub fn as_secs(&self) -> u64 ``` -------------------------------- ### Method: connect_with Source: https://docs.rs/pingora-rustls/0.8.0/pingora_rustls/struct.TlsConnector.html?search=std%3A%3Avec Establishes an asynchronous TLS connection with a custom configuration callback. ```APIDOC ## [METHOD] connect_with ### Description Establishes a TLS connection, allowing for custom configuration of the ClientConnection before the handshake. ### Method Rust Function (Async) ### Parameters #### Arguments - **domain** (ServerName<'static>) - Required - The target server domain name. - **stream** (IO) - Required - The underlying IO stream. - **f** (FnOnce(&mut ClientConnection)) - Required - A closure to modify the client connection. ### Response - **Connect** - Returns a connection future. ### Request Example ```rust connector.connect_with(domain, stream, |conn| { // Custom logic here }).await ``` ``` -------------------------------- ### Get Signature from DigitallySignedStruct in Rust Source: https://docs.rs/pingora-rustls/0.8.0/pingora_rustls/struct.DigitallySignedStruct.html Provides a method to retrieve the signature payload from a DigitallySignedStruct. This method returns a byte slice representing the signature. ```rust pub fn signature(&self) -> &[u8] ``` -------------------------------- ### load_platform_certs_incl_env_into_store Source: https://docs.rs/pingora-rustls/0.8.0/pingora_rustls/fn.load_platform_certs_incl_env_into_store.html?search=u32+-%3E+bool Function to load native platform CA certificates into a provided RootCertStore. ```APIDOC ## [FUNCTION] load_platform_certs_incl_env_into_store ### Description Attempts to load the native system Certificate Authorities (CAs), including those specified via environment variables, into the provided `RootCertStore`. ### Method Rust Function Call ### Endpoint pingora_rustls::load_platform_certs_incl_env_into_store ### Parameters #### Arguments - **ca_certs** (&mut RootCertStore) - Required - A mutable reference to the root certificate store where the loaded certificates will be added. ### Request Example ```rust let mut store = RootCertStore::empty(); load_platform_certs_incl_env_into_store(&mut store)?; ``` ### Response #### Success Response (Ok) - **Result** (()) - Returns an empty unit type on success. #### Error Response (Err) - **Result** (Error) - Returns an error if the platform certificates could not be loaded. ``` -------------------------------- ### ClientConfig Builder Source: https://docs.rs/pingora-rustls/0.8.0/pingora_rustls/struct.ClientConfig.html?search=std%3A%3Avec Provides a builder for creating a client configuration without default implementation details. This is intended for `no_std` environments and requires explicit `TimeProvider` and `CryptoProvider` implementations. ```APIDOC ## POST /websites/rs_pingora-rustls_0_8_0_pingora_rustls/builder_with_details ### Description Creates a builder for a client configuration with no default implementation details. This API must be used by `no_std` users. You must provide a specific `TimeProvider` and `CryptoProvider`. This will use the provider’s configured ciphersuites. You must additionally choose which protocol versions to enable, using `with_protocol_versions` or `with_safe_default_protocol_versions` and handling the `Result` in case a protocol version is not supported by the provider’s ciphersuites. For more information, see the `ConfigBuilder` documentation. ### Method POST ### Endpoint /websites/rs_pingora-rustls_0_8_0_pingora_rustls/builder_with_details ### Parameters #### Query Parameters - **provider** (Arc) - Required - The cryptographic provider to use. - **time_provider** (Arc) - Required - The time provider to use. ### Request Body None ### Response #### Success Response (200) - **ConfigBuilder** - A builder for the client configuration. #### Response Example ```json { "message": "Builder created successfully" } ``` ``` -------------------------------- ### Get DER-Encoded Private Key Bytes in Rust Source: https://docs.rs/pingora-rustls/0.8.0/pingora_rustls/enum.PrivateKeyDer.html?search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E A method to retrieve the raw DER-encoded bytes of the private key. This can be useful for further processing or serialization. ```rust pub fn secret_der(&self) -> &[u8] ``` -------------------------------- ### ServerConfig Builder with Details (no_std) Source: https://docs.rs/pingora-rustls/0.8.0/pingora_rustls/struct.ServerConfig.html?search=std%3A%3Avec Creates a server configuration builder for `no_std` environments, requiring explicit `CryptoProvider` and `TimeProvider`. Protocol versions must be configured separately. ```APIDOC ## POST /websites/rs_pingora-rustls_0_8_0_pingora_rustls/builder_with_details ### Description Creates a builder for a server configuration with no default implementation details, suitable for `no_std` users. Requires a specific `TimeProvider` and `CryptoProvider`. ### Method POST ### Endpoint /websites/rs_pingora-rustls_0_8_0_pingora_rustls/builder_with_details ### Parameters #### Request Body - **provider** (Arc) - Required - The specific CryptoProvider to use. - **time_provider** (Arc) - Required - The specific TimeProvider to use. ### Request Example ```json { "provider": "", "time_provider": "" } ``` ### Response #### Success Response (200) - **builder** (ConfigBuilder) - A configuration builder instance. #### Response Example ```json { "builder": "" } ``` ``` -------------------------------- ### ASCII Manipulation Methods for Byte Slices Source: https://docs.rs/pingora-rustls/0.8.0/pingora_rustls/struct.CertificateDer.html?search=std%3A%3Avec Examples of common slice operations available on CertificateDer, including ASCII escaping and whitespace trimming. ```rust let s = b"0\t\r\n'\"\\\x9d"; let escaped = s.escape_ascii().to_string(); assert_eq!(escaped, "0\\t\\r\\n\\'\\\"\\\\\\x9d"); assert_eq!(b" \t hello world\n".trim_ascii_start(), b"hello world\n"); assert_eq!(b"\r hello world\n ".trim_ascii_end(), b"\r hello world"); assert_eq!(b"\r hello world\n ".trim_ascii(), b"hello world"); ``` -------------------------------- ### Get First Byte of CertificateDer Slice in Rust Source: https://docs.rs/pingora-rustls/0.8.0/pingora_rustls/struct.CertificateDer.html?search= Returns an `Option` containing a reference to the first byte of the `CertificateDer` slice, or `None` if the slice is empty. ```rust pub fn first(&self) -> Option<&u8> // Example: // let v = [10, 40, 30]; // assert_eq!(Some(&10), v.first()); ``` -------------------------------- ### ServerConfig Builder Methods Source: https://docs.rs/pingora-rustls/0.8.0/pingora_rustls/struct.ServerConfig.html?search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E Methods for creating and configuring a server configuration builder. ```APIDOC ## POST /websites/rs_pingora-rustls_0_8_0_pingora_rustls/builder_with_protocol_versions ### Description Create a builder for a server configuration with the process-default `CryptoProvider` and the provided protocol versions. Panics if: * the supported versions are not compatible with the provider (eg. the combination of ciphersuites supported by the provider and supported versions lead to zero cipher suites being usable), * if a `CryptoProvider` cannot be resolved using a combination of the crate features and process default. For more information, see the `ConfigBuilder` documentation. ### Method POST ### Endpoint /websites/rs_pingora-rustls_0_8_0_pingora_rustls/builder_with_protocol_versions ### Parameters #### Query Parameters - **versions** (array of strings) - Required - A list of supported protocol versions. ### Request Example ```json { "versions": ["TLSv1.2", "TLSv1.3"] } ``` ### Response #### Success Response (200) - **ConfigBuilder** (object) - The server configuration builder. #### Response Example ```json { "builder": "ConfigBuilder" } ``` ## POST /websites/rs_pingora-rustls_0_8_0_pingora_rustls/builder_with_provider ### Description Create a builder for a server configuration with a specific `CryptoProvider`. This will use the provider’s configured ciphersuites. You must additionally choose which protocol versions to enable, using `with_protocol_versions` or `with_safe_default_protocol_versions` and handling the `Result` in case a protocol version is not supported by the provider’s ciphersuites. For more information, see the `ConfigBuilder` documentation. ### Method POST ### Endpoint /websites/rs_pingora-rustls_0_8_0_pingora_rustls/builder_with_provider ### Parameters #### Request Body - **provider** (Arc) - Required - The specific crypto provider to use. ### Request Example ```json { "provider": "" } ``` ### Response #### Success Response (200) - **ConfigBuilder** (object) - The server configuration builder. #### Response Example ```json { "builder": "ConfigBuilder" } ``` ## POST /websites/rs_pingora-rustls_0_8_0_pingora_rustls/builder_with_details ### Description Create a builder for a server configuration with no default implementation details. This API must be used by `no_std` users. You must provide a specific `TimeProvider` and a specific `CryptoProvider`. This will use the provider’s configured ciphersuites. You must additionally choose which protocol versions to enable, using `with_protocol_versions` or `with_safe_default_protocol_versions` and handling the `Result` in case a protocol version is not supported by the provider’s ciphersuites. For more information, see the `ConfigBuilder` documentation. ### Method POST ### Endpoint /websites/rs_pingora-rustls_0_8_0_pingora_rustls/builder_with_details ### Parameters #### Request Body - **provider** (Arc) - Required - The specific crypto provider to use. - **time_provider** (Arc) - Required - The specific time provider to use. ### Request Example ```json { "provider": "", "time_provider": "" } ``` ### Response #### Success Response (200) - **ConfigBuilder** (object) - The server configuration builder. #### Response Example ```json { "builder": "ConfigBuilder" } ``` ``` -------------------------------- ### ServerConfig Builder Initialization Source: https://docs.rs/pingora-rustls/0.8.0/pingora_rustls/struct.ServerConfig.html Initializes a builder for creating a server configuration. It uses the process-default CryptoProvider and safe default protocol versions. Refer to the ConfigBuilder documentation for detailed usage. ```rust pub fn builder() -> ConfigBuilder ``` -------------------------------- ### Get First Element of CertificateDer Slice (Rust) Source: https://docs.rs/pingora-rustls/0.8.0/pingora_rustls/struct.CertificateDer.html Returns an Option containing a reference to the first element of the CertificateDer slice, or None if the slice is empty. ```rust pub fn first(&self) -> Option<&T> ```