pub struct ClientBuilder<D> where
    D: AsRef<str>, 
{ /* private fields */ }
Expand description

A convenience builder for Client structs over various encrypted transports.

Creating a Client using native-tls transport is straightforward:

let client = ClientBuilder::new("imap.example.com", 993).native_tls()?;

Similarly, if using the rustls-tls feature you can create a Client using rustls:

let client = ClientBuilder::new("imap.example.com", 993).rustls()?;

To use STARTTLS, just call starttls() before one of the Client-yielding functions:

let client = ClientBuilder::new("imap.example.com", 993)
    .starttls()
    .rustls()?;

The returned Client is unauthenticated; to access session-related methods (through Session), use Client::login or Client::authenticate.

Implementations

Make a new ClientBuilder using the given domain and port.

Use STARTTLS for this connection.

Return a new Client using a native-tls transport.

Make a Client using a custom TLS initialization. This function is intended to be used if your TLS setup requires custom work such as adding private CAs or other specific TLS parameters.

The handshake argument should accept two parameters:

and yield a Result<C> where C is Read + Write. It should only perform TLS initialization over the given tcp socket and return the encrypted stream object, such as a native_tls::TlsStream or a [rustls_connector::TlsStream].

If the caller is using STARTTLS and previously called starttls then the tcp socket given to the handshake function will be connected and will have initiated the STARTTLS handshake.

let client = ClientBuilder::new("imap.example.com", 993)
    .starttls()
    .connect(|domain, tcp| {
        let ssl_conn = RustlsConnector::new_with_native_certs()?;
        Ok(ssl_conn.connect(domain, tcp)?)
    })?;

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

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

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.