Struct NetTransportOptions

Source
pub struct NetTransportOptions<I, A: AddressResolver<ResolvedAddress = SocketAddr>, S: StreamLayer> { /* private fields */ }
Expand description

Used to configure a net transport.

Implementations§

Source§

impl<I, A: AddressResolver<ResolvedAddress = SocketAddr>, S: StreamLayer> NetTransportOptions<I, A, S>

Source

pub const fn id(&self) -> &I

Get the id of the node.

Source

pub const fn bind_addresses(&self) -> &IndexSet<A::Address>

Get a set of addresses to bind to for both TCP and UDP communications.

Source

pub const fn resolver(&self) -> &A::Options

Get the address resolver options.

Source

pub const fn stream_layer(&self) -> &S::Options

Get the stream layer options.

Source

pub const fn cidrs_policy(&self) -> &CIDRsPolicy

Get the policy for Classless Inter-Domain Routing (CIDR).

Source

pub const fn max_packet_size(&self) -> usize

Get the maximum payload size can be sent by UDP. Default is 1472 bytes.

Source

pub const fn recv_buffer_size(&self) -> usize

Get the UDP receive window. Default is 2MB.

Source

pub fn metric_labels(&self) -> Option<&MetricLabels>

Available on crate feature metrics only.

Get the metrics labels.

Source

pub fn with_id(self, val: I) -> Self

Set the id of the node. (Builder pattern)

Source

pub fn with_bind_addresses(self, val: IndexSet<A::Address>) -> Self

Set the set of addresses to bind to for both TCP and UDP communications. (Builder pattern)

Source

pub fn with_resolver(self, val: A::Options) -> Self

Set the address resolver options. (Builder pattern)

Source

pub fn with_stream_layer(self, val: S::Options) -> Self

Set the stream layer options. (Builder pattern)

Source

pub fn with_cidrs_policy(self, val: CIDRsPolicy) -> Self

Set the policy for Classless Inter-Domain Routing (CIDR). (Builder pattern)

Source

pub fn with_max_packet_size(self, val: usize) -> Self

Set the maximum payload size can be sent by UDP. Default is 1472 bytes. (Builder pattern)

Source

pub fn with_recv_buffer_size(self, val: usize) -> Self

Set the UDP receive window. Default is 2MB. (Builder pattern)

Source

pub fn with_metric_labels(self, val: Option<Arc<MetricLabels>>) -> Self

Available on crate feature metrics only.

Set the metrics labels. (Builder pattern)

Source§

impl<I, A: AddressResolver<ResolvedAddress = SocketAddr>, S: StreamLayer> NetTransportOptions<I, A, S>
where A::Options: Default, S::Options: Default,

Source

pub fn new(id: I) -> Self

Creates a new net transport options by id, other configurations are left default.

Source§

impl<I, A: AddressResolver<ResolvedAddress = SocketAddr>, S: StreamLayer> NetTransportOptions<I, A, S>
where S::Options: Default,

Source

pub fn with_resolver_options(id: I, resolver_options: A::Options) -> Self

Creates a new net transport options by id and resolver options, other configurations are left default.

Source§

impl<I, A: AddressResolver<ResolvedAddress = SocketAddr>, S: StreamLayer> NetTransportOptions<I, A, S>
where A::Options: Default,

Source

pub fn with_stream_layer_options( id: I, stream_layer_options: S::Options, ) -> Self

Creates a new net transport options by id and stream layer options, other configurations are left default.

Source§

impl<I, A: AddressResolver<ResolvedAddress = SocketAddr>, S: StreamLayer> NetTransportOptions<I, A, S>

Source

pub fn with_resolver_options_and_stream_layer_options( id: I, resolver_options: A::Options, stream_layer_opts: S::Options, ) -> Self

Creates a new net transport options by id, resolver options and stream layer options, other configurations are left default.

Source

pub fn add_bind_address(&mut self, addr: A::Address) -> &mut Self

Add bind address

Trait Implementations§

Source§

impl<I, A: AddressResolver<ResolvedAddress = SocketAddr>, S: StreamLayer> Clone for NetTransportOptions<I, A, S>
where I: Clone, A::Options: Clone, S::Options: Clone,

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl<I: Debug, A: Debug + AddressResolver<ResolvedAddress = SocketAddr>, S: Debug + StreamLayer> Debug for NetTransportOptions<I, A, S>
where A::Address: Debug, A::Options: Debug, S::Options: Debug,

Source§

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

Formats the value using the given formatter. Read more
Source§

impl<'de, I, A, S: StreamLayer> Deserialize<'de> for NetTransportOptions<I, A, S>
where I: Deserialize<'de>, A: AddressResolver + AddressResolver<ResolvedAddress = SocketAddr>, A::Address: Deserialize<'de>, A::ResolvedAddress: Deserialize<'de>, A::Options: Deserialize<'de>, S::Options: Deserialize<'de>,

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl<I, A: AddressResolver<ResolvedAddress = SocketAddr>, S: StreamLayer> From<NetTransportOptions<I, A, S>> for (A::Options, S::Options, Options<I, A>)

Source§

fn from( opts: NetTransportOptions<I, A, S>, ) -> (A::Options, S::Options, Options<I, A>)

Converts to this type from the input type.
Source§

impl<I, A, S: StreamLayer> Serialize for NetTransportOptions<I, A, S>

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

§

impl<I, A, S> Freeze for NetTransportOptions<I, A, S>

§

impl<I, A, S> RefUnwindSafe for NetTransportOptions<I, A, S>

§

impl<I, A, S> Send for NetTransportOptions<I, A, S>
where I: Send, <A as AddressResolver>::Address: Send,

§

impl<I, A, S> Sync for NetTransportOptions<I, A, S>
where I: Sync, <A as AddressResolver>::Address: Sync,

§

impl<I, A, S> Unpin for NetTransportOptions<I, A, S>

§

impl<I, A, S> UnwindSafe for NetTransportOptions<I, A, 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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

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

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

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

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

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

Source§

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

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.
Source§

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

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

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

fn with_current_subscriber(self) -> WithDispatch<Self>

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

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> ErasedDestructor for T
where T: 'static,