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§

§

impl Builder

pub fn new() -> Builder

Builds a new Builder. See Builder methods for defaults.

Examples
use fabruic::Builder;

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

pub fn set_address(&mut self, address: SocketAddr)

Set’s the SocketAddr to bind to.

Default

[::\]:0.

Examples
use fabruic::Builder;

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

pub const fn address(&self) -> &SocketAddr

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);

pub fn set_reuse_address(&mut self, reuse: bool)

Enables SO_REUSEADDR on the underlying UdpSocket, allowing multiple Endpoints to bind to the same SocketAddr.

If this is false, attempting to create an Endpoint to a previously bound SocketAddr may result in an address-in-use error.

pub const fn reuse_address(&self) -> bool

Returns whether the underlying UdpSocket will enable the SO_REUSEADDR option. See set_reuse_address() for more information.

pub fn set_server_key_pair(&mut self, key_pair: Option<KeyPair>)

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")));

pub const fn server_key_pair(&self) -> &Option<KeyPair>

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))

pub fn set_client_key_pair(&mut self, key_pair: Option<KeyPair>)

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")));

pub const fn client_key_pair(&self) -> &Option<KeyPair>

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))

pub fn set_protocols<P>(&mut self, protocols: P)
where P: Into<Vec<Vec<u8>>>,

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()]);

pub fn protocols(&self) -> &[Vec<u8>]

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)

pub fn set_trust_dns(&mut self, enable: bool)

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);

pub fn disable_trust_dns(&mut self)

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();

pub const fn trust_dns(&self) -> bool

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);

pub fn set_dnssec(&mut self, enable: bool)

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);

pub const fn dnssec(&self) -> bool

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);

pub fn set_hosts_file(&mut self, enable: bool)

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);

pub const fn hosts_file(&self) -> bool

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);

pub fn set_store(&mut self, store: Store)

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);

pub const fn store(&self) -> Store

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);

pub fn set_max_idle_timeout( &mut self, time: Option<Duration> ) -> Result<(), Config>

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.

pub const fn max_idle_timeout(&self) -> Option<Duration>

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)));

pub fn build(self) -> Result<Endpoint, Builder>

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§

§

impl Dangerous for Builder

§

fn set_root_certificates<C>(builder: &mut Builder, certificates: C)
where C: Into<Vec<Certificate>>,

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
§

fn root_certificates(builder: &Builder) -> &[Certificate]

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

impl Clone for Builder

§

fn clone(&self) -> Builder

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
§

impl Debug for Builder

§

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

Formats the value using the given formatter. Read more
§

impl Default for Builder

§

fn default() -> Builder

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

Auto Trait Implementations§

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
§

impl<'a, T, E> AsTaggedExplicit<'a, E> for T
where T: 'a,

§

fn explicit(self, class: Class, tag: u32) -> TaggedParser<'a, Explicit, Self, E>

§

impl<'a, T, E> AsTaggedImplicit<'a, E> for T
where T: 'a,

§

fn implicit( self, class: Class, constructed: bool, tag: u32 ) -> TaggedParser<'a, Implicit, Self, E>

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.

§

impl<T> Instrument for T

§

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

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

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> Same for T

§

type Output = T

Should always be Self
source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

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

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.
§

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

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

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
§

fn with_current_subscriber(self) -> WithDispatch<Self>

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