pub struct P2PConfigBuilder { /* private fields */ }
Expand description
Builder for P2PConfig
This builder provides a fluent API for creating a P2PConfig.
§Example
use ant_quic::api::config::P2PConfigBuilder;
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 = P2PConfigBuilder::new()
.with_bootstrap_nodes(vec![BootstrapNode::new(bootstrap_addr)])
.with_keypair(key_utils::generate_ed25519_keypair())
.with_nat_traversal(true)
.build()
.unwrap();
Implementations§
Source§impl P2PConfigBuilder
impl P2PConfigBuilder
Sourcepub fn with_bootstrap_nodes<T: Into<Vec<BootstrapNode>>>(
&mut self,
nodes: T,
) -> &mut Self
pub fn with_bootstrap_nodes<T: Into<Vec<BootstrapNode>>>( &mut self, nodes: T, ) -> &mut Self
Set the bootstrap nodes
Bootstrap nodes are used for NAT traversal coordination. At least one bootstrap node is required if NAT traversal is enabled.
Sourcepub fn add_bootstrap_node(&mut self, node: BootstrapNode) -> &mut Self
pub fn add_bootstrap_node(&mut self, node: BootstrapNode) -> &mut Self
Add a bootstrap node
Sourcepub fn with_keypair(
&mut self,
keypair: (Ed25519SecretKey, Ed25519PublicKey),
) -> &mut Self
pub fn with_keypair( &mut self, keypair: (Ed25519SecretKey, Ed25519PublicKey), ) -> &mut Self
Set the keypair for authentication
Sourcepub fn with_nat_traversal(&mut self, enabled: bool) -> &mut Self
pub fn with_nat_traversal(&mut self, enabled: bool) -> &mut Self
Enable or disable NAT traversal
Sourcepub fn with_listen_address(&mut self, address: SocketAddr) -> &mut Self
pub fn with_listen_address(&mut self, address: SocketAddr) -> &mut Self
Set the listen address
Sourcepub fn with_connection_timeout(&mut self, timeout: Duration) -> &mut Self
pub fn with_connection_timeout(&mut self, timeout: Duration) -> &mut Self
Set the connection timeout
Sourcepub fn with_max_connection_attempts(&mut self, attempts: u32) -> &mut Self
pub fn with_max_connection_attempts(&mut self, attempts: u32) -> &mut Self
Set the maximum number of connection attempts
Sourcepub fn with_max_concurrent_connections(&mut self, connections: u32) -> &mut Self
pub fn with_max_concurrent_connections(&mut self, connections: u32) -> &mut Self
Set the maximum number of concurrent connections
Sourcepub fn with_nat_traversal_config(
&mut self,
config: NatTraversalConfig,
) -> &mut Self
pub fn with_nat_traversal_config( &mut self, config: NatTraversalConfig, ) -> &mut Self
Set advanced NAT traversal configuration
Sourcepub fn build(&self) -> ConfigResult<P2PConfig>
pub fn build(&self) -> ConfigResult<P2PConfig>
Build the configuration
This method validates the configuration and returns a P2PConfig
if valid.
If the configuration is invalid, it returns a ConfigError
.
Trait Implementations§
Source§impl Clone for P2PConfigBuilder
impl Clone for P2PConfigBuilder
Source§fn clone(&self) -> P2PConfigBuilder
fn clone(&self) -> P2PConfigBuilder
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreSource§impl Debug for P2PConfigBuilder
impl Debug for P2PConfigBuilder
Auto Trait Implementations§
impl Freeze for P2PConfigBuilder
impl RefUnwindSafe for P2PConfigBuilder
impl Send for P2PConfigBuilder
impl Sync for P2PConfigBuilder
impl Unpin for P2PConfigBuilder
impl UnwindSafe for P2PConfigBuilder
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