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>
impl<T: EventHandler + Clone + Send + Sync + 'static> CoreBuilder<T>
sourcepub fn with_config(config: BootstrapConfig, handler: T) -> Self
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.
sourcepub fn with_network_id(self, protocol: String) -> Self
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
.
sourcepub fn listen_on(self, ip_address: IpAddr) -> Self
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
.
sourcepub fn with_idle_connection_timeout(self, keep_alive_duration: Seconds) -> Self
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.
sourcepub fn with_stream_size(self, size: usize) -> Self
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
.
sourcepub fn with_ping(self, config: PingConfig) -> Self
pub fn with_ping(self, config: PingConfig) -> Self
Configure the Ping
protocol for the network.
sourcepub fn with_rpc<F>(self, config: RpcConfig) -> Self
pub fn with_rpc<F>(self, config: RpcConfig) -> Self
Configure the RPC protocol for the network.
sourcepub fn with_kademlia(self, config: Config) -> Self
pub fn with_kademlia(self, config: Config) -> Self
Configure the Kademlia
protocol for the network.
sourcepub fn with_gossipsub(self, config: Config, auth: MessageAuthenticity) -> Self
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.
sourcepub fn with_transports(self, transport: TransportOpts) -> Self
pub fn with_transports(self, transport: TransportOpts) -> Self
Configure the transports to support.
sourcepub fn configure_network_events(self, handler: T) -> Self
pub fn configure_network_events(self, handler: T) -> Self
Configure a handler to respond to network events.
sourcepub fn network_id(&self) -> String
pub fn network_id(&self) -> String
Return the id of the network.
sourcepub async fn build(self) -> SwarmNlResult<Core<T>>
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§
§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
source§impl<T> IntoEither for T
impl<T> IntoEither for T
source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moresource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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