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>

source

pub fn new(state: T) -> Self

source§

impl ClientBuilder<CloudWantsCertAndKey>

source

pub fn keep_alive<T: TryIntoU64>(self, interval: T) -> Result<Self>

source

pub fn backoff_strategy(self, strategy: BackoffStrategy) -> Self

source

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>

source

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>

source

pub fn keep_alive<T: TryIntoU64>(self, interval: T) -> Result<Self>

source

pub fn backoff_strategy(self, strategy: BackoffStrategy) -> Self

source

pub fn endpoint(self, endpoint: &str) -> ClientBuilder<CustomWantsRootCert>

Specifies the remote server address to connect to.

source§

impl ClientBuilder<CustomWantsRootCert>

source

pub fn with_certificate_authority<T: AsRef<Path>>( self, ca_path: T ) -> Result<ClientBuilder<CustomWantsCertAndKey>>

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>

source

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>

source

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.

Trait Implementations§

source§

impl<T: Debug> Debug for ClientBuilder<T>

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<T> Freeze for ClientBuilder<T>
where T: Freeze,

§

impl<T> RefUnwindSafe for ClientBuilder<T>
where T: RefUnwindSafe,

§

impl<T> Send for ClientBuilder<T>
where T: Send,

§

impl<T> Sync for ClientBuilder<T>
where T: Sync,

§

impl<T> Unpin for ClientBuilder<T>
where T: Unpin,

§

impl<T> UnwindSafe for ClientBuilder<T>
where T: UnwindSafe,

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T> Instrument for T

source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

source§

fn vzip(self) -> V

source§

impl<T> WithSubscriber for T

source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more