libp2p::swarm

Struct Config

pub struct Config { /* private fields */ }

Implementations§

§

impl Config

pub fn with_executor(executor: impl Executor + Send + 'static) -> Config

Creates a new Config from the given executor. The Swarm is obtained via Swarm::new.

pub fn with_wasm_executor() -> Config

Available on crate feature wasm-bindgen only.

Sets executor to the wasm executor. Background tasks will be executed by the browser on the next micro-tick.

Spawning a task is similar too:

function spawn(task: () => Promise<void>) {
    task()
}

pub fn with_tokio_executor() -> Config

Available on crate feature tokio and neither Emscripten nor WASI nor target_os="unknown" only.

Builds a new Config from the given tokio executor.

pub fn with_async_std_executor() -> Config

Available on crate feature async-std and neither Emscripten nor WASI nor target_os="unknown" only.

Builds a new Config from the given async-std executor.

pub fn with_notify_handler_buffer_size(self, n: NonZero<usize>) -> Config

Configures the number of events from the NetworkBehaviour in destination to the ConnectionHandler that can be buffered before the Swarm has to wait. An individual buffer with this number of events exists for each individual connection.

The ideal value depends on the executor used, the CPU speed, and the volume of events. If this value is too low, then the Swarm will be sleeping more often than necessary. Increasing this value increases the overall memory usage.

pub fn with_per_connection_event_buffer_size(self, n: usize) -> Config

Configures the size of the buffer for events sent by a ConnectionHandler to the NetworkBehaviour.

Each connection has its own buffer.

The ideal value depends on the executor used, the CPU speed and the volume of events. If this value is too low, then the ConnectionHandlers will be sleeping more often than necessary. Increasing this value increases the overall memory usage, and more importantly the latency between the moment when an event is emitted and the moment when it is received by the NetworkBehaviour.

pub fn with_dial_concurrency_factor(self, factor: NonZero<u8>) -> Config

Number of addresses concurrently dialed for a single outbound connection attempt.

pub fn with_substream_upgrade_protocol_override(self, v: Version) -> Config

Configures an override for the substream upgrade protocol to use.

The subtream upgrade protocol is the multistream-select protocol used for protocol negotiation on substreams. Since a listener supports all existing versions, the choice of upgrade protocol only effects the “dialer”, i.e. the peer opening a substream.

Note: If configured, specific upgrade protocols for individual SubstreamProtocols emitted by the NetworkBehaviour are ignored.

pub fn with_max_negotiating_inbound_streams(self, v: usize) -> Config

The maximum number of inbound streams concurrently negotiating on a connection. New inbound streams exceeding the limit are dropped and thus reset.

Note: This only enforces a limit on the number of concurrently negotiating inbound streams. The total number of inbound streams on a connection is the sum of negotiating and negotiated streams. A limit on the total number of streams can be enforced at the StreamMuxerBox level.

pub fn with_idle_connection_timeout(self, timeout: Duration) -> Config

How long to keep a connection alive once it is idling.

Defaults to 0.

Auto Trait Implementations§

§

impl Freeze for Config

§

impl !RefUnwindSafe for Config

§

impl Send for Config

§

impl !Sync for Config

§

impl Unpin for Config

§

impl !UnwindSafe for Config

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

§

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

impl<T> Pointable for T

§

const ALIGN: usize = _

The alignment of pointer.
§

type Init = T

The type for initializers.
§

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

Initializes a with the given initializer. Read more
§

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

Dereferences the given pointer. Read more
§

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

Mutably dereferences the given pointer. Read more
§

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