#[non_exhaustive]pub struct NodeConfig {
pub should_connect: bool,
pub is_gateway: bool,
pub key_pair: TransportKeypair,
pub network_listener_ip: IpAddr,
pub network_listener_port: u16,
/* private fields */
}Expand description
When instancing a node you can either join an existing network or bootstrap a new network with a listener which will act as the initial provider. This initial peer will be listening at the provided port and assigned IP. If those are not free the instancing process will return an error.
In order to bootstrap a new network the following arguments are required to be provided to the builder:
- ip: IP associated to the initial node.
- port: listening port of the initial node.
If both are provided but also additional peers are added via the Self::add_gateway() method, this node will
be listening but also try to connect to an existing peer.
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.should_connect: boolDetermines if an initial connection should be attempted. Only true for an initial gateway/node. If false, the gateway will be disconnected unless other peers connect through it.
is_gateway: bool§key_pair: TransportKeypairIf not specified, a key is generated and used when creating the node.
network_listener_ip: IpAddrIP to bind to the network listener.
network_listener_port: u16socket port to bind to the network listener.
Implementations§
Source§impl NodeConfig
impl NodeConfig
pub async fn new(config: Config) -> Result<NodeConfig>
pub fn config(&self) -> &Config
pub fn is_gateway(&mut self) -> &mut Self
pub fn first_gateway(&mut self)
pub fn with_should_connect(&mut self, should_connect: bool) -> &mut Self
pub fn max_hops_to_live(&mut self, num_hops: usize) -> &mut Self
pub fn rnd_if_htl_above(&mut self, num_hops: usize) -> &mut Self
pub fn max_number_of_connections(&mut self, num: usize) -> &mut Self
pub fn min_number_of_connections(&mut self, num: usize) -> &mut Self
pub fn with_own_addr(&mut self, addr: SocketAddr) -> &mut Self
pub fn with_location(&mut self, loc: Location) -> &mut Self
Sourcepub fn add_gateway(&mut self, peer: InitPeerNode) -> &mut Self
pub fn add_gateway(&mut self, peer: InitPeerNode) -> &mut Self
Connection info for an already existing peer. Required in case this is not a gateway node.
Sourcepub async fn build<const CLIENTS: usize>(
self,
clients: [Box<dyn ClientEventsProxy + Send + 'static>; CLIENTS],
) -> Result<Node>
pub async fn build<const CLIENTS: usize>( self, clients: [Box<dyn ClientEventsProxy + Send + 'static>; CLIENTS], ) -> Result<Node>
Builds a node using the default backend connection manager.
Sourcepub async fn build_with_flush_handle<const CLIENTS: usize>(
self,
clients: [Box<dyn ClientEventsProxy + Send + 'static>; CLIENTS],
) -> Result<(Node, EventFlushHandle)>
pub async fn build_with_flush_handle<const CLIENTS: usize>( self, clients: [Box<dyn ClientEventsProxy + Send + 'static>; CLIENTS], ) -> Result<(Node, EventFlushHandle)>
Builds a node and returns flush handle for event aggregation (for testing).
pub fn get_own_addr(&self) -> Option<SocketAddr>
Trait Implementations§
Source§impl Clone for NodeConfig
impl Clone for NodeConfig
Source§fn clone(&self) -> NodeConfig
fn clone(&self) -> NodeConfig
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for NodeConfig
impl Debug for NodeConfig
Source§impl<'de> Deserialize<'de> for NodeConfig
impl<'de> Deserialize<'de> for NodeConfig
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Auto Trait Implementations§
impl Freeze for NodeConfig
impl RefUnwindSafe for NodeConfig
impl Send for NodeConfig
impl Sync for NodeConfig
impl Unpin for NodeConfig
impl UnwindSafe for NodeConfig
Blanket Implementations§
Source§impl<T> ArchivePointee for T
impl<T> ArchivePointee for T
Source§type ArchivedMetadata = ()
type ArchivedMetadata = ()
Source§fn pointer_metadata(
_: &<T as ArchivePointee>::ArchivedMetadata,
) -> <T as Pointee>::Metadata
fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§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 moreSource§impl<T> LayoutRaw for T
impl<T> LayoutRaw for T
Source§fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
Source§impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
Source§unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool
unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool
Source§fn resolve_niched(out: Place<NichedOption<T, N1>>)
fn resolve_niched(out: Place<NichedOption<T, N1>>)
out indicating that a T is niched.