pub struct Builder { /* private fields */ }
Expand description

Helper for constructing an Endpoint.

Examples

use fabruic::{Builder, Store};

let mut builder = Builder::new();
builder.set_protocols([b"test".to_vec()]);
builder.set_store(Store::Os);
let endpoint = builder.build()?;

Implementations

Builds a new Builder. See Builder methods for defaults.

Examples
use fabruic::Builder;

let mut endpoint = Builder::new().build()?;

Set’s the SocketAddr to bind to.

Default

[::\]:0.

Examples
use fabruic::Builder;

let mut builder = Builder::new();
builder.set_address("[::1]:0".parse()?);

Returns the SocketAddr to bind to.

See set_address.

Examples
use fabruic::Builder;

let mut builder = Builder::new();

let address = "[::1]:0".parse()?;
builder.set_address(address);
assert_eq!(builder.address(), &address);

Set a server certificate KeyPair, use None to remove any server certificate.

Default

None.

Notes

Endpoint won’t listen to any incoming Connections without a server certificate.

Examples
use fabruic::{Builder, KeyPair};

let mut builder = Builder::new();
builder.set_server_key_pair(Some(KeyPair::new_self_signed("test")));

Returns the server certificate KeyPair.

See set_server_key_pair.

Examples
use fabruic::{Builder, KeyPair};

let mut builder = Builder::new();

let key_pair = KeyPair::new_self_signed("test");
builder.set_server_key_pair(Some(key_pair.clone()));
assert_eq!(builder.server_key_pair(), &Some(key_pair))

Set a client certificate KeyPair, use None to remove any client certificate.

Default

None.

Examples
use fabruic::{Builder, KeyPair};

let mut builder = Builder::new();
builder.set_client_key_pair(Some(KeyPair::new_self_signed("test")));

Returns the client certificate KeyPair.

See set_client_key_pair.

Examples
use fabruic::{Builder, KeyPair};

let mut builder = Builder::new();

let key_pair = KeyPair::new_self_signed("test");
builder.set_client_key_pair(Some(key_pair.clone()));
assert_eq!(builder.client_key_pair(), &Some(key_pair))

Set the protocols to accept, in order of descending preference. When set, clients which don’t declare support for at least one of the supplied protocols will be rejected.

See Connection::protocol.

Default

No protocols.

Examples
use fabruic::Builder;

let mut builder = Builder::new();
builder.set_protocols([b"test".to_vec()]);

Returns the set protocols.

See set_protocols.

Examples
use fabruic::Builder;

let mut builder = Builder::new();

let protocols = [b"test".to_vec()];
builder.set_protocols(protocols.clone());
assert_eq!(builder.protocols(), protocols)
This is supported on crate feature trust-dns only.

Controls the use of trust-dns for Endpoint::connect.

Default

true if the crate feature trust-dns is enabled.

Examples
use fabruic::Builder;

let mut builder = Builder::new();
builder.set_trust_dns(false);

Disables the use of trust-dns for Endpoint::connect despite the activated crate feature.

Default

Not disabled if the crate feature trust-dns is enabled.

Examples
use fabruic::Builder;

let mut builder = Builder::new();
builder.disable_trust_dns();

Returns if trust-dns is enabled.

See set_trust_dns or disable_trust_dns.

Examples
use fabruic::Builder;

let mut builder = Builder::new();

builder.set_trust_dns(true);
assert_eq!(builder.trust_dns(), true);

builder.disable_trust_dns();
assert_eq!(builder.trust_dns(), false);
This is supported on crate feature trust-dns only.

Controls DNSSEC validation for trust-dns in Endpoint::connect. This doesn’t affect the ToSocketAddrs resolver.

Default

true.

Examples
use fabruic::Builder;

let mut builder = Builder::new();
builder.set_dnssec(false);
This is supported on crate feature trust-dns only.

Returns if DNSSEC is enabled for trust-dns.

See set_dnssec.

Examples
use fabruic::Builder;

let mut builder = Builder::new();

builder.set_dnssec(false);
assert_eq!(builder.dnssec(), false);
This is supported on crate feature trust-dns only.

Controls /etc/hosts file support for trust-dns in Endpoint::connect. This doesn’t affect the ToSocketAddrs resolver.

Default

false. Only affects UNIX like OS’s.

Examples
use fabruic::Builder;

let mut builder = Builder::new();
builder.set_hosts_file(false);
This is supported on crate feature trust-dns only.

Returns if /etc/hosts file support is enabled for trust-dns.

See set_dnssec.

Examples
use fabruic::Builder;

let mut builder = Builder::new();

builder.set_hosts_file(true);
assert_eq!(builder.hosts_file(), true);

Set’s the default root certificate store.

See Store for more details.

Default

Store::Embedded.

Examples
use fabruic::{Builder, Store};

let mut builder = Builder::new();
builder.set_store(Store::Os);

Returns the set Store.

See set_store.

Examples
use fabruic::{Builder, Store};

let mut builder = Builder::new();

// default
assert_eq!(builder.store(), Store::Embedded);

builder.set_store(Store::Os);
assert_eq!(builder.store(), Store::Os);

builder.set_store(Store::Empty);
assert_eq!(builder.store(), Store::Empty);

Set’s the maximum idle timeout a client can have before getting automatically disconnected. Set None to disable automatic disconnecting completely.

Default

10s

Examples
use std::time::Duration;

use fabruic::{Builder, Store};

let mut builder = Builder::new();
builder.set_max_idle_timeout(Some(Duration::from_millis(1000)));
Errors

Config::MaxIdleTimeout if time exceeds 2^62 ms.

Returns the set Duration specified for idle clients to automatically get disconnected. None means clients don’t get automatically disconnected.

See set_max_idle_timeout.

Examples
use std::time::Duration;

use fabruic::{Builder, Store};

let mut builder = Builder::new();

// default
assert_eq!(builder.max_idle_timeout(), Some(Duration::from_secs(10)));

builder.set_max_idle_timeout(None);
assert_eq!(builder.max_idle_timeout(), None);

builder.set_max_idle_timeout(Some(Duration::from_secs(30)));
assert_eq!(builder.max_idle_timeout(), Some(Duration::from_secs(30)));

Consumes Builder to build Endpoint. Must be called from inside a Tokio Runtime.

Errors

error::Builder if the socket couldn’t be bound to the given address.

Panics
Examples
use fabruic::Builder;

let endpoint = Builder::new().build()?;

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

This is supported on crate feature dangerous only.

Set Certificates to be added into the root certificate store for connecting to a server. This is added additionally to the Store root certificates and does not replace them. Read more

This is supported on crate feature dangerous only.

Returns Certificates set to be added into the root certificate store. Read more

Formats the value using the given formatter. Read more

Returns the “default value” for a type. Read more

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.

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

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

Calls U::from(self).

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

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

🔬 This is a nightly-only experimental API. (toowned_clone_into)

Uses borrowed data to replace owned data, usually by cloning. Read more

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.

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

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