Skip to main content

ConfigBuilder

Struct ConfigBuilder 

Source
pub struct ConfigBuilder<S: State = Empty> { /* private fields */ }
Expand description

Use builder syntax to set the inputs and finish with internal_build().

Implementations§

Source§

impl<S: State> ConfigBuilder<S>

Source

pub(crate) fn internal_build(self) -> Config
where S: IsComplete,

Finish building and return the requested object

Source

pub fn name(self, s: impl Into<String>) -> ConfigBuilder<SetName<S>>
where S::Name: IsUnset,

Required.

Network name.

Source

pub fn noise_protocols( self, it: impl IntoIterator<Item = (Version, Protocol)>, ) -> ConfigBuilder<SetNoiseProtocols<S>>

Required.

The supported noise protocols.

Nodes negotiate a common supported version which implies the exact noise protocol parameters they are going to use for the subsequent handshake.

With this map, a node specifies the noise protocol names it supports per version number.

Source

pub fn keypair(self, value: Keypair) -> ConfigBuilder<SetKeypair<S>>
where S::Keypair: IsUnset,

Required.

DH keypair

Source

pub fn bind(self, value: NetAddr) -> ConfigBuilder<SetBind<S>>
where S::Bind: IsUnset,

Required.

Address to bind to.

Source

pub fn parties( self, iter: impl IntoIterator<Item = (PublicKey, NetAddr)>, ) -> ConfigBuilder<SetParties<S>>
where S::Parties: IsUnset,

Required.

Network members with public key and network address.

Source

pub fn peer_budget(self, value: NonZeroUsize) -> ConfigBuilder<SetPeerBudget<S>>
where S::PeerBudget: IsUnset,

Optional (Some / Option setters). Default: NonZeroUsize::new(100).expect("100 > 0").

Source

pub fn maybe_peer_budget( self, value: Option<NonZeroUsize>, ) -> ConfigBuilder<SetPeerBudget<S>>
where S::PeerBudget: IsUnset,

Optional (Some / Option setters). Default: NonZeroUsize::new(100).expect("100 > 0").

Source

pub fn max_message_size( self, value: NonZeroUsize, ) -> ConfigBuilder<SetMaxMessageSize<S>>

Optional (Some / Option setters). Default: NonZeroUsize::new(10485760).expect("10485760 > 0").

Max. number of bytes per message to send or receive.

Source

pub fn maybe_max_message_size( self, value: Option<NonZeroUsize>, ) -> ConfigBuilder<SetMaxMessageSize<S>>

Optional (Some / Option setters). Default: NonZeroUsize::new(10485760).expect("10485760 > 0").

Max. number of bytes per message to send or receive.

Source

pub fn connect_retry_delays( self, it: impl IntoIterator<Item = u8>, ) -> ConfigBuilder<SetConnectRetryDelays<S>>

Optional (Some / Option setters). Default: NonEmpty::new(1, [3, 5, 15, 30]).

Connect retry delays in seconds.

Source

pub fn maybe_connect_retry_delays( self, value: Option<impl IntoIterator<Item = u8>>, ) -> ConfigBuilder<SetConnectRetryDelays<S>>

Optional (Some / Option setters). Default: NonEmpty::new(1, [3, 5, 15, 30]).

Connect retry delays in seconds.

Source

pub fn send_retry_delays( self, it: impl IntoIterator<Item = u8>, ) -> ConfigBuilder<SetSendRetryDelays<S>>

Optional (Some / Option setters). Default: NonEmpty::new(5, [15, 30]).

Send retry delays in seconds.

Source

pub fn maybe_send_retry_delays( self, value: Option<impl IntoIterator<Item = u8>>, ) -> ConfigBuilder<SetSendRetryDelays<S>>

Optional (Some / Option setters). Default: NonEmpty::new(5, [15, 30]).

Send retry delays in seconds.

Source

pub fn random_connect_delay( self, value: bool, ) -> ConfigBuilder<SetRandomConnectDelay<S>>

Optional (Some / Option setters). Default: true.

Randomly delay the initial connect attempt between 0 and 1s.

Source

pub fn maybe_random_connect_delay( self, value: Option<bool>, ) -> ConfigBuilder<SetRandomConnectDelay<S>>

Optional (Some / Option setters). Default: true.

Randomly delay the initial connect attempt between 0 and 1s.

Source

pub fn connect_timeout( self, value: Duration, ) -> ConfigBuilder<SetConnectTimeout<S>>

Optional (Some / Option setters). Default: Duration::from_secs(30).

How long to wait to establish a TCP connection?

Source

pub fn maybe_connect_timeout( self, value: Option<Duration>, ) -> ConfigBuilder<SetConnectTimeout<S>>

Optional (Some / Option setters). Default: Duration::from_secs(30).

How long to wait to establish a TCP connection?

Source

pub fn handshake_timeout( self, value: Duration, ) -> ConfigBuilder<SetHandshakeTimeout<S>>

Optional (Some / Option setters). Default: Duration::from_secs(10).

How long to wait for a noise handshake to complete?

Source

pub fn maybe_handshake_timeout( self, value: Option<Duration>, ) -> ConfigBuilder<SetHandshakeTimeout<S>>

Optional (Some / Option setters). Default: Duration::from_secs(10).

How long to wait for a noise handshake to complete?

Source

pub fn receive_timeout( self, value: Duration, ) -> ConfigBuilder<SetReceiveTimeout<S>>

Optional (Some / Option setters). Default: Duration::from_secs(30).

After sending a message we expect to hear back from the peer.

If we do not receive anything for this duration we reconnect.

Source

pub fn maybe_receive_timeout( self, value: Option<Duration>, ) -> ConfigBuilder<SetReceiveTimeout<S>>

Optional (Some / Option setters). Default: Duration::from_secs(30).

After sending a message we expect to hear back from the peer.

If we do not receive anything for this duration we reconnect.

Source

pub fn backoff_duration( self, value: Duration, ) -> ConfigBuilder<SetBackoffDuration<S>>

Optional (Some / Option setters). Default: Duration::from_secs(30).

If a party is not known we tell it to back off for this amount of time.

This may happen when not all peers have a consistent configuration.

Source

pub fn maybe_backoff_duration( self, value: Option<Duration>, ) -> ConfigBuilder<SetBackoffDuration<S>>

Optional (Some / Option setters). Default: Duration::from_secs(30).

If a party is not known we tell it to back off for this amount of time.

This may happen when not all peers have a consistent configuration.

Source

pub fn metrics(self, value: Arc<dyn Metrics>) -> ConfigBuilder<SetMetrics<S>>
where S::Metrics: IsUnset,

Optional (Some / Option setters). Optional metrics implementation.

Source

pub fn maybe_metrics( self, value: Option<Arc<dyn Metrics>>, ) -> ConfigBuilder<SetMetrics<S>>
where S::Metrics: IsUnset,

Optional (Some / Option setters). Optional metrics implementation.

Source§

impl<S: IsComplete> ConfigBuilder<S>

Source

pub fn build(self) -> Config

Auto Trait Implementations§

§

impl<S> Freeze for ConfigBuilder<S>

§

impl<S = Empty> !RefUnwindSafe for ConfigBuilder<S>

§

impl<S> Send for ConfigBuilder<S>

§

impl<S> Sync for ConfigBuilder<S>

§

impl<S> Unpin for ConfigBuilder<S>

§

impl<S> UnsafeUnpin for ConfigBuilder<S>

§

impl<S = Empty> !UnwindSafe for ConfigBuilder<S>

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.

§

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

Source§

type Output = T

Should always be Self
Source§

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

Source§

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

Source§

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