Skip to main content

Config

Struct Config 

Source
pub struct Config {
Show 21 fields pub load_balance: LoadBalance, pub major_socket_count: usize, pub route_idle_time: Duration, pub udp_tunnel_config: Option<UdpTunnelConfig>, pub tcp_tunnel_config: Option<TcpTunnelConfig>, pub group_code: Option<GroupCode>, pub self_id: Option<NodeID>, pub direct_addrs: Option<Vec<PeerNodeAddress>>, pub send_buffer_size: usize, pub recv_buffer_size: usize, pub query_id_interval: Duration, pub query_id_max_num: usize, pub heartbeat_interval: Duration, pub tcp_stun_servers: Option<Vec<String>>, pub udp_stun_servers: Option<Vec<String>>, pub mapping_addrs: Option<Vec<NodeAddress>>, pub dns: Option<Vec<String>>, pub recycle_buf_cap: usize, pub default_interface: Option<LocalInterface>, pub use_v6: bool, pub punching_policy: Option<Arc<dyn PunchingPolicy>>,
}
Expand description

Configuration for creating a P2P endpoint.

Config contains all the parameters needed to configure a P2P node, including network settings, encryption, NAT traversal, and routing options.

§Examples

use rustp2p::Config;
use std::net::Ipv4Addr;

let config = Config::empty()
    .set_node_id(Ipv4Addr::new(10, 0, 0, 1).into());

Fields§

§load_balance: LoadBalance§major_socket_count: usize§route_idle_time: Duration§udp_tunnel_config: Option<UdpTunnelConfig>§tcp_tunnel_config: Option<TcpTunnelConfig>§group_code: Option<GroupCode>§self_id: Option<NodeID>§direct_addrs: Option<Vec<PeerNodeAddress>>§send_buffer_size: usize§recv_buffer_size: usize§query_id_interval: Duration§query_id_max_num: usize§heartbeat_interval: Duration§tcp_stun_servers: Option<Vec<String>>§udp_stun_servers: Option<Vec<String>>§mapping_addrs: Option<Vec<NodeAddress>>§dns: Option<Vec<String>>§recycle_buf_cap: usize§default_interface: Option<LocalInterface>§use_v6: bool§punching_policy: Option<Arc<dyn PunchingPolicy>>

Implementations§

Source§

impl Config

Source

pub fn none_tcp(self) -> Self

Source§

impl Config

Source

pub fn empty() -> Self

Source

pub fn set_load_balance(self, load_balance: LoadBalance) -> Self

Source

pub fn set_main_socket_count(self, count: usize) -> Self

Source

pub fn set_udp_tunnel_config(self, config: UdpTunnelConfig) -> Self

Source

pub fn set_tcp_tunnel_config(self, config: TcpTunnelConfig) -> Self

Source

pub fn set_group_code(self, group_code: GroupCode) -> Self

Source

pub fn set_node_id(self, self_id: NodeID) -> Self

Source

pub fn set_direct_addrs(self, direct_addrs: Vec<PeerNodeAddress>) -> Self

Source

pub fn set_send_buffer_size(self, send_buffer_size: usize) -> Self

Source

pub fn set_recv_buffer_size(self, recv_buffer_size: usize) -> Self

Source

pub fn set_query_id_interval(self, query_id_interval: Duration) -> Self

Source

pub fn set_query_id_max_num(self, query_id_max_num: usize) -> Self

Source

pub fn set_heartbeat_interval(self, heartbeat_interval: Duration) -> Self

Source

pub fn set_tcp_stun_servers(self, tcp_stun_servers: Vec<String>) -> Self

Source

pub fn set_udp_stun_servers(self, udp_stun_servers: Vec<String>) -> Self

Source

pub fn set_mapping_addrs(self, mapping_addrs: Vec<NodeAddress>) -> Self

Other nodes will attempt to connect to the current node through this configuration

Source

pub fn set_dns(self, dns: Vec<String>) -> Self

Source

pub fn set_recycle_buf_cap(self, recycle_buf_cap: usize) -> Self

Source

pub fn set_default_interface(self, default_interface: LocalInterface) -> Self

Bind to this network card

Source

pub fn set_use_v6(self, use_v6: bool) -> Self

Whether to use IPv6

Source

pub fn set_punching_policy<T: PunchingPolicy + 'static>( self, punching_policy: T, ) -> Self

Source

pub fn set_punching_policy_arc( self, punching_policy: Arc<dyn PunchingPolicy + 'static>, ) -> Self

Trait Implementations§

Source§

impl Default for Config

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl From<Config> for TunnelConfig

Source§

fn from(value: Config) -> Self

Converts to this type from the input type.

Auto Trait Implementations§

§

impl Freeze for Config

§

impl !RefUnwindSafe for Config

§

impl Send for Config

§

impl Sync for Config

§

impl Unpin for Config

§

impl !UnwindSafe for Config

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> FromRef<T> for U
where T: Clone, U: From<T>,

Source§

fn from_ref(val_ref: &T) -> U

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V