Struct selium::ClientBuilder
source · pub struct ClientBuilder<T> { /* private fields */ }
Expand description
A convenient builder struct used to build a Client instance.
The ClientBuilder uses a type-level Finite State Machine to assure that a Client cannot be constructed with an invalid state. For example, the connect method will not be in-scope unless the ClientBuilder is in a pre-connection state, which is achieved by first configuring the root store and keypair.
NOTE: The ClientBuilder type is not intended to be used directly. Use the cloud or custom functions to construct a ClientBuilder in its initial state.
Implementations§
source§impl<T> ClientBuilder<T>
impl<T> ClientBuilder<T>
source§impl ClientBuilder<CloudWantsCertAndKey>
impl ClientBuilder<CloudWantsCertAndKey>
sourcepub fn keep_alive<T: TryIntoU64>(self, interval: T) -> Result<Self>
pub fn keep_alive<T: TryIntoU64>(self, interval: T) -> Result<Self>
See keep_alive in ClientCommon.
sourcepub fn backoff_strategy(self, strategy: BackoffStrategy) -> Self
pub fn backoff_strategy(self, strategy: BackoffStrategy) -> Self
See backoff_strategy in ClientCommon.
sourcepub fn with_cert_and_key<T: AsRef<Path>>(
self,
cert_file: T,
key_file: T
) -> Result<ClientBuilder<CloudWantsConnect>>
pub fn with_cert_and_key<T: AsRef<Path>>( self, cert_file: T, key_file: T ) -> Result<ClientBuilder<CloudWantsConnect>>
Attempts to load a valid keypair from the filesystem to use with authenticating the QUIC connection.
Keypairs can be encoded in either a Base64 ASCII (.pem) or binary (.der) format.
Following this method, the ClientBuilder will be in a pre-connection state, so any additional configuration must take place before invoking this method.
§Errors
Returns Err under the following conditions:
-
The provided
cert_file
argument does not refer to a file containing a valid certificate. -
The provided
key_file
argument does not refer to a file containing a valid PKCS-8 private key.
source§impl ClientBuilder<CloudWantsConnect>
impl ClientBuilder<CloudWantsConnect>
sourcepub async fn connect(self) -> Result<Client>
pub async fn connect(self) -> Result<Client>
Attempts to establish a connection with Selium Cloud
.
The connect method will only be in scope if the
ClientBuilder is in a pre-connect state, CloudWantsConnect
.
§Errors
Returns Err under the following conditions:
- If the connection cannot be established.
source§impl ClientBuilder<CustomWantsEndpoint>
impl ClientBuilder<CustomWantsEndpoint>
sourcepub fn keep_alive<T: TryIntoU64>(self, interval: T) -> Result<Self>
pub fn keep_alive<T: TryIntoU64>(self, interval: T) -> Result<Self>
See keep_alive in ClientCommon.
sourcepub fn backoff_strategy(self, strategy: BackoffStrategy) -> Self
pub fn backoff_strategy(self, strategy: BackoffStrategy) -> Self
See backoff_strategy in ClientCommon.
sourcepub fn endpoint(self, endpoint: &str) -> ClientBuilder<CustomWantsRootCert>
pub fn endpoint(self, endpoint: &str) -> ClientBuilder<CustomWantsRootCert>
Specifies the remote server address to connect to.
source§impl ClientBuilder<CustomWantsRootCert>
impl ClientBuilder<CustomWantsRootCert>
Attempts to load a valid CA certificate from the filesystem, and creates a root cert store to use with authenticating the QUIC connection.
Certificates can be encoded in either a Base64 ASCII (.pem) or binary (.der) format.
§Errors
Returns Err if the provided ca_path
argument does not refer to a file containing a
valid certificate.
source§impl ClientBuilder<CustomWantsCertAndKey>
impl ClientBuilder<CustomWantsCertAndKey>
sourcepub fn with_cert_and_key<T: AsRef<Path>>(
self,
cert_file: T,
key_file: T
) -> Result<ClientBuilder<CustomWantsConnect>>
pub fn with_cert_and_key<T: AsRef<Path>>( self, cert_file: T, key_file: T ) -> Result<ClientBuilder<CustomWantsConnect>>
Attempts to load a valid keypair from the filesystem to use with authenticating the QUIC connection.
Keypairs can be encoded in either a Base64 ASCII (.pem) or binary (.der) format.
Following this method, the ClientBuilder will be in a pre-connection state, so any additional configuration must take place before invoking this method.
§Errors
Returns Err under the following conditions:
-
The provided
cert_file
argument does not refer to a file containing a valid certificate. -
The provided
key_file
argument does not refer to a file containing a valid PKCS-8 private key.
source§impl ClientBuilder<CustomWantsConnect>
impl ClientBuilder<CustomWantsConnect>
sourcepub async fn connect(self) -> Result<Client>
pub async fn connect(self) -> Result<Client>
Attempts to establish a connection with the Selium
server corresponding to the provided
addr
argument. The connect method will only be in scope if the
ClientBuilder is in a pre-connect state, CustomWantsConnect
.
§Errors
Returns Err under the following conditions:
- If the provided
addr
argument does not resolve to a valid SocketAddr. - If the connection cannot be established.