Struct swarm_nl::core::CoreBuilder

source ·
pub struct CoreBuilder<T: EventHandler + Clone + Send + Sync + 'static> { /* private fields */ }
Expand description

Structure containing necessary data to build Core.

Implementations§

source§

impl<T: EventHandler + Clone + Send + Sync + 'static> CoreBuilder<T>

source

pub fn with_config(config: BootstrapConfig, handler: T) -> Self

Return a CoreBuilder struct configured with BootstrapConfig and default values. Here, it is certain that BootstrapConfig contains valid data. A type that implements EventHandler is passed to handle and responde to network events.

source

pub fn with_network_id(self, protocol: String) -> Self

Explicitly configure the network (protocol) id.

Note that it must be of the format “/protocol-name/version” otherwise it will default to “/swarmnl/1.0”. See: DEFAULT_NETWORK_ID.

source

pub fn listen_on(self, ip_address: IpAddr) -> Self

Configure the IP address to listen on.

If none is specified, the default value is Ipv4Addr::new(0, 0, 0, 0). See: DEFAULT_IP_ADDRESS.

source

pub fn with_idle_connection_timeout(self, keep_alive_duration: Seconds) -> Self

Configure how long to keep a connection alive (in seconds) once it is idling.

source

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

Configure the size of the stream buffers to use to track application requests to the network layer internally. This should be as large an possible to prevent dropping off requests to the network layer. Defaults to usize::MAX.

source

pub fn with_ping(self, config: PingConfig) -> Self

Configure the Ping protocol for the network.

source

pub fn with_rpc<F>(self, config: RpcConfig) -> Self

Configure the RPC protocol for the network.

source

pub fn with_kademlia(self, config: Config) -> Self

Configure the Kademlia protocol for the network.

source

pub fn with_gossipsub(self, config: Config, auth: MessageAuthenticity) -> Self

Configure the Gossipsub protocol for the network.

§Panics

This function panics if Gossipsub cannot be configured properly.

source

pub fn with_transports(self, transport: TransportOpts) -> Self

Configure the transports to support.

source

pub fn configure_network_events(self, handler: T) -> Self

Configure a handler to respond to network events.

source

pub fn network_id(&self) -> String

Return the id of the network.

source

pub async fn build(self) -> SwarmNlResult<Core<T>>

Build the Core data structure.

Handles the configuration of the libp2p Swarm structure and the selected transport protocols, behaviours and node identity for tokio and async-std runtimes. The Swarm is wrapped in the Core construct which serves as the interface to interact with the internal networking layer.

Auto Trait Implementations§

§

impl<T> Freeze for CoreBuilder<T>
where T: Freeze,

§

impl<T> !RefUnwindSafe for CoreBuilder<T>

§

impl<T> Send for CoreBuilder<T>

§

impl<T> Sync for CoreBuilder<T>

§

impl<T> Unpin for CoreBuilder<T>
where T: Unpin,

§

impl<T> !UnwindSafe for CoreBuilder<T>

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

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