Struct litep2p::protocol::notification::ConfigBuilder

source ·
pub struct ConfigBuilder { /* private fields */ }
Expand description

Notification configuration builder.

Implementations§

source§

impl ConfigBuilder

source

pub fn new(protocol_name: ProtocolName) -> Self

Create new ConfigBuilder.

source

pub fn with_max_size(self, max_notification_size: usize) -> Self

Set maximum notification size.

source

pub fn with_handshake(self, handshake: Vec<u8>) -> Self

Set handshake.

source

pub fn with_fallback_names(self, fallback_names: Vec<ProtocolName>) -> Self

Set fallback names.

source

pub fn with_auto_accept_inbound(self, auto_accept: bool) -> Self

Auto-accept inbound substreams for those connections which were initiated by the local node.

Connection in this context means a bidirectional substream pair between two peers over a given protocol.

By default, when a node starts a connection with a remote node and opens an outbound substream to them, that substream is validated and if it’s accepted, remote node sends their handshake over that substream and opens another substream to local node. The substream that was opened by the local node is used for sending data and the one opened by the remote node is used for receiving data.

By default, even if the local node was the one that opened the first substream, this inbound substream coming from remote node must be validated as the handshake of the remote node may reveal that it’s not someone that the local node is willing to accept.

To disable this behavior, auto accepting for the inbound substream can be enabled. If local node is the one that opened the connection and it was accepted by the remote node, local node is only notified via NotificationStreamOpened.

source

pub fn with_sync_channel_size(self, size: usize) -> Self

Configure size of the channel for sending synchronous notifications.

Default value is 16.

source

pub fn with_async_channel_size(self, size: usize) -> Self

Configure size of the channel for sending asynchronous notifications.

Default value is 8.

source

pub fn with_dialing_enabled(self, should_dial: bool) -> Self

Should NotificationProtocol attempt to dial the peer if an outbound substream is opened but no connection to the peer exist.

Dialing is enabled by default.

source

pub fn build(self) -> (Config, NotificationHandle)

Build notification configuration.

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> Any for T
where T: Any,

source§

fn into_any(self: Box<T>) -> Box<dyn Any>

source§

fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>

source§

fn type_name(&self) -> &'static str

source§

impl<T> AnySync for T
where T: Any + Send + Sync,

source§

fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Send + Sync>

source§

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

source§

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

source§

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

source§

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.

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

§

type Output = T

Should always be Self
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.
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