pub struct NetworkConfig {Show 13 fields
pub listen_addrs: Vec<String>,
pub bootstrap_peers: Vec<String>,
pub enable_quic: bool,
pub data_dir: PathBuf,
pub enable_mdns: bool,
pub enable_nat_traversal: bool,
pub relay_servers: Vec<String>,
pub kademlia: KademliaConfig,
pub max_connections: Option<usize>,
pub max_inbound_connections: Option<usize>,
pub max_outbound_connections: Option<usize>,
pub connection_buffer_size: usize,
pub low_memory_mode: bool,
}Expand description
Network configuration
Fields§
§listen_addrs: Vec<String>Listen addresses
bootstrap_peers: Vec<String>Bootstrap peers
enable_quic: boolEnable QUIC transport
data_dir: PathBufData directory
enable_mdns: boolEnable mDNS peer discovery
enable_nat_traversal: boolEnable NAT traversal (AutoNAT + DCUtR)
relay_servers: Vec<String>Relay server addresses for NAT traversal
kademlia: KademliaConfigKademlia DHT configuration
max_connections: Option<usize>Maximum number of concurrent connections (None = unlimited)
max_inbound_connections: Option<usize>Maximum number of inbound connections (None = unlimited)
max_outbound_connections: Option<usize>Maximum number of outbound connections (None = unlimited)
connection_buffer_size: usizeConnection buffer size in bytes
low_memory_mode: boolEnable aggressive memory optimizations
Implementations§
Source§impl NetworkConfig
impl NetworkConfig
Sourcepub fn low_memory() -> Self
pub fn low_memory() -> Self
Create a low-memory configuration for constrained devices
This configuration minimizes memory usage at the cost of some features:
- Limited to 16 total connections
- Smaller connection buffers (8 KB)
- Reduced DHT parameters
- mDNS disabled
- NAT traversal disabled
Suitable for embedded devices with < 128 MB RAM
Sourcepub fn iot() -> Self
pub fn iot() -> Self
Create an IoT device configuration
Balanced configuration for IoT devices:
- Limited to 32 total connections
- Moderate connection buffers (16 KB)
- Reduced DHT parameters
- mDNS enabled for local discovery
- NAT traversal enabled
Suitable for IoT devices with 128-512 MB RAM
Sourcepub fn mobile() -> Self
pub fn mobile() -> Self
Create a mobile device configuration
Power and bandwidth-aware configuration for mobile devices:
- Limited to 64 total connections
- Standard connection buffers (32 KB)
- Standard DHT parameters
- mDNS disabled (battery saving)
- NAT traversal enabled
Suitable for mobile devices with network switching
Sourcepub fn high_performance() -> Self
pub fn high_performance() -> Self
Create a high-performance configuration for servers
Optimized for high throughput and many connections:
- Unlimited connections
- Large connection buffers (128 KB)
- Aggressive DHT parameters
- All features enabled
Suitable for servers with > 2 GB RAM
Trait Implementations§
Source§impl Clone for NetworkConfig
impl Clone for NetworkConfig
Source§fn clone(&self) -> NetworkConfig
fn clone(&self) -> NetworkConfig
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for NetworkConfig
impl Debug for NetworkConfig
Auto Trait Implementations§
impl Freeze for NetworkConfig
impl RefUnwindSafe for NetworkConfig
impl Send for NetworkConfig
impl Sync for NetworkConfig
impl Unpin for NetworkConfig
impl UnwindSafe for NetworkConfig
Blanket Implementations§
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§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
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 more