Skip to main content

Config

Struct Config 

Source
#[non_exhaustive]
pub struct Config {
Show 15 fields pub(crate) name: Arc<String>, pub(crate) noise_protocols: NonEmpty<BTreeMap<Version, Protocol>>, pub(crate) keypair: Keypair, pub(crate) bind: NetAddr, pub(crate) parties: Vec<(PublicKey, NetAddr)>, pub(crate) peer_budget: NonZeroUsize, pub(crate) max_message_size: NonZeroUsize, pub(crate) connect_retry_delays: NonEmpty<Vec<u8>>, pub(crate) send_retry_delays: NonEmpty<Vec<u8>>, pub(crate) random_connect_delay: bool, pub(crate) connect_timeout: Duration, pub(crate) handshake_timeout: Duration, pub(crate) receive_timeout: Duration, pub(crate) backoff_duration: Duration, pub(crate) metrics: Option<Arc<dyn Metrics>>,
}

Fields (Non-exhaustive)§

This struct is marked as non-exhaustive
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.
§name: Arc<String>

Network name.

§noise_protocols: NonEmpty<BTreeMap<Version, Protocol>>

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.

§keypair: Keypair

DH keypair

§bind: NetAddr

Address to bind to.

§parties: Vec<(PublicKey, NetAddr)>

Network members with public key and network address.

§peer_budget: NonZeroUsize§max_message_size: NonZeroUsize

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

§connect_retry_delays: NonEmpty<Vec<u8>>

Connect retry delays in seconds.

§send_retry_delays: NonEmpty<Vec<u8>>

Send retry delays in seconds.

§random_connect_delay: bool

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

§connect_timeout: Duration

How long to wait to establish a TCP connection?

§handshake_timeout: Duration

How long to wait for a noise handshake to complete?

§receive_timeout: Duration

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

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

§backoff_duration: Duration

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.

§metrics: Option<Arc<dyn Metrics>>

Optional metrics implementation.

Implementations§

Source§

impl Config

Source

pub fn builder() -> ConfigBuilder

Create an instance of Config using the builder syntax

Source§

impl Config

Source

pub fn public_key(&self) -> PublicKey

Source

pub fn with_metrics<M: Metrics + 'static>(self, m: M) -> Self

Trait Implementations§

Source§

impl Debug for Config

Source§

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

Formats the value using the given formatter. 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
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