pub struct P2PConfig { /* private fields */ }
Expand description
P2P configuration
This struct contains all configuration options for a P2P node.
Use the builder pattern via P2PConfig::builder()
to create a configuration.
§Example
use ant_quic::api::config::P2PConfig;
use ant_quic::crypto::raw_public_keys::key_utils;
use ant_quic::nat_traversal::BootstrapNode;
use std::net::SocketAddr;
let bootstrap_addr: SocketAddr = "127.0.0.1:9000".parse().unwrap();
let config = P2PConfig::builder()
.with_bootstrap_nodes(vec![BootstrapNode::new(bootstrap_addr)])
.with_keypair(key_utils::generate_ed25519_keypair())
.with_nat_traversal(true)
.build()
.unwrap();
Implementations§
Source§impl P2PConfig
impl P2PConfig
Sourcepub fn builder() -> P2PConfigBuilder
pub fn builder() -> P2PConfigBuilder
Create a new configuration builder
§Example
use ant_quic::api::config::P2PConfig;
let builder = P2PConfig::builder();
Sourcepub fn bootstrap_nodes(&self) -> &[BootstrapNode]
pub fn bootstrap_nodes(&self) -> &[BootstrapNode]
Get the bootstrap nodes
Sourcepub fn keypair(&self) -> &(Ed25519SecretKey, Ed25519PublicKey)
pub fn keypair(&self) -> &(Ed25519SecretKey, Ed25519PublicKey)
Get the keypair
Sourcepub fn nat_traversal_enabled(&self) -> bool
pub fn nat_traversal_enabled(&self) -> bool
Check if NAT traversal is enabled
Sourcepub fn listen_address(&self) -> SocketAddr
pub fn listen_address(&self) -> SocketAddr
Get the listen address
Sourcepub fn connection_timeout(&self) -> Duration
pub fn connection_timeout(&self) -> Duration
Get the connection timeout
Sourcepub fn max_connection_attempts(&self) -> u32
pub fn max_connection_attempts(&self) -> u32
Get the maximum number of connection attempts
Sourcepub fn max_concurrent_connections(&self) -> u32
pub fn max_concurrent_connections(&self) -> u32
Get the maximum number of concurrent connections
Sourcepub fn nat_traversal_config(&self) -> Option<&NatTraversalConfig>
pub fn nat_traversal_config(&self) -> Option<&NatTraversalConfig>
Get the advanced NAT traversal configuration
Trait Implementations§
Auto Trait Implementations§
impl Freeze for P2PConfig
impl RefUnwindSafe for P2PConfig
impl Send for P2PConfig
impl Sync for P2PConfig
impl Unpin for P2PConfig
impl UnwindSafe for P2PConfig
Blanket Implementations§
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
Mutably borrows from an owned value. Read more