pub struct NetAdapterConfig {Show 17 fields
pub bind_addr: SocketAddr,
pub peer_addr: SocketAddr,
pub psk: [u8; 32],
pub role: ConnectionRole,
pub static_keypair: Option<StaticKeypair>,
pub peer_static_pubkey: Option<[u8; 32]>,
pub default_reliability: ReliabilityConfig,
pub packet_pool_size: usize,
pub heartbeat_interval: Duration,
pub session_timeout: Duration,
pub batched_io: bool,
pub handshake_retries: usize,
pub handshake_timeout: Duration,
pub socket_recv_buffer: Option<usize>,
pub socket_send_buffer: Option<usize>,
pub num_shards: u16,
pub entity_keypair: Option<EntityKeypair>,
}Expand description
Configuration for the Net adapter.
Fields§
§bind_addr: SocketAddrLocal bind address
peer_addr: SocketAddrRemote peer address
psk: [u8; 32]Pre-shared key (32 bytes)
role: ConnectionRoleConnection role (initiator or responder)
static_keypair: Option<StaticKeypair>Our static keypair (required for responder)
peer_static_pubkey: Option<[u8; 32]>Peer’s static public key (required for initiator)
default_reliability: ReliabilityConfigDefault reliability mode for new streams
packet_pool_size: usizePacket pool size
heartbeat_interval: DurationHeartbeat interval
session_timeout: DurationSession timeout
batched_io: boolEnable batched I/O (sendmmsg/recvmmsg on Linux)
handshake_retries: usizeMaximum retries for handshake
handshake_timeout: DurationHandshake timeout
socket_recv_buffer: Option<usize>Socket receive buffer size (None = use system default of 64MB)
socket_send_buffer: Option<usize>Socket send buffer size (None = use system default of 64MB)
num_shards: u16Number of shards (used to map stream IDs to shard IDs on receive)
entity_keypair: Option<EntityKeypair>Entity keypair for L1 identity (optional — if absent, origin_hash stays 0)
Implementations§
Source§impl NetAdapterConfig
impl NetAdapterConfig
Sourcepub const DEFAULT_POOL_SIZE: usize = 64
pub const DEFAULT_POOL_SIZE: usize = 64
Default packet pool size
Sourcepub const DEFAULT_HEARTBEAT_INTERVAL: Duration
pub const DEFAULT_HEARTBEAT_INTERVAL: Duration
Default heartbeat interval
Sourcepub const DEFAULT_SESSION_TIMEOUT: Duration
pub const DEFAULT_SESSION_TIMEOUT: Duration
Default session timeout
Sourcepub const DEFAULT_HANDSHAKE_RETRIES: usize = 3
pub const DEFAULT_HANDSHAKE_RETRIES: usize = 3
Default handshake retries
Sourcepub const DEFAULT_HANDSHAKE_TIMEOUT: Duration
pub const DEFAULT_HANDSHAKE_TIMEOUT: Duration
Default handshake timeout
Sourcepub const MAX_PACKET_POOL_SIZE: usize
pub const MAX_PACKET_POOL_SIZE: usize
Upper bound on packet_pool_size. Pre-fix this was 1 << 20
(1 048 576), which sounds defensive but ThreadLocalPool:: with_local_capacity eagerly pre-allocates size
PacketBuilder instances of ~16 KB each — at the old ceiling
that’s ~16 GiB up-front per session, a guaranteed OOM. The
cap was intended to prevent OOM; pre-fix it just postponed
the death by one validation step. 16 384 is well past every
realistic production setting (the default is 64) while
bounding the worst-case at ~256 MiB.
Sourcepub const MAX_HANDSHAKE_RETRIES: usize = 1024
pub const MAX_HANDSHAKE_RETRIES: usize = 1024
Upper bound on handshake_retries. Pre-fix
unbounded; a misconfigured large value just took forever to
fail. 1024 covers any realistic flaky-network policy; the
default is 3.
Sourcepub fn initiator(
bind_addr: SocketAddr,
peer_addr: SocketAddr,
psk: [u8; 32],
peer_static_pubkey: [u8; 32],
) -> Self
pub fn initiator( bind_addr: SocketAddr, peer_addr: SocketAddr, psk: [u8; 32], peer_static_pubkey: [u8; 32], ) -> Self
Create a new initiator configuration.
The initiator must know the responder’s static public key.
Sourcepub fn responder(
bind_addr: SocketAddr,
peer_addr: SocketAddr,
psk: [u8; 32],
static_keypair: StaticKeypair,
) -> Self
pub fn responder( bind_addr: SocketAddr, peer_addr: SocketAddr, psk: [u8; 32], static_keypair: StaticKeypair, ) -> Self
Create a new responder configuration.
The responder provides its static keypair for authentication.
Sourcepub fn with_num_shards(self, num_shards: u16) -> Self
pub fn with_num_shards(self, num_shards: u16) -> Self
Set the number of shards
Sourcepub fn with_entity_keypair(self, keypair: EntityKeypair) -> Self
pub fn with_entity_keypair(self, keypair: EntityKeypair) -> Self
Set the entity keypair for L1 identity
Sourcepub fn with_reliability(self, reliability: ReliabilityConfig) -> Self
pub fn with_reliability(self, reliability: ReliabilityConfig) -> Self
Set the default reliability mode
Sourcepub fn with_pool_size(self, size: usize) -> Self
pub fn with_pool_size(self, size: usize) -> Self
Set the packet pool size
Sourcepub fn with_heartbeat_interval(self, interval: Duration) -> Self
pub fn with_heartbeat_interval(self, interval: Duration) -> Self
Set the heartbeat interval
Sourcepub fn with_session_timeout(self, timeout: Duration) -> Self
pub fn with_session_timeout(self, timeout: Duration) -> Self
Set the session timeout
Sourcepub fn with_batched_io(self, enabled: bool) -> Self
pub fn with_batched_io(self, enabled: bool) -> Self
Enable or disable batched I/O
Sourcepub fn with_handshake(self, retries: usize, timeout: Duration) -> Self
pub fn with_handshake(self, retries: usize, timeout: Duration) -> Self
Set handshake configuration
Sourcepub fn with_socket_buffers(self, recv_size: usize, send_size: usize) -> Self
pub fn with_socket_buffers(self, recv_size: usize, send_size: usize) -> Self
Set socket buffer sizes (useful for testing with smaller buffers)
Sourcepub fn is_initiator(&self) -> bool
pub fn is_initiator(&self) -> bool
Check if this is an initiator configuration
Sourcepub fn is_responder(&self) -> bool
pub fn is_responder(&self) -> bool
Check if this is a responder configuration
Trait Implementations§
Source§impl Clone for NetAdapterConfig
impl Clone for NetAdapterConfig
Source§fn clone(&self) -> NetAdapterConfig
fn clone(&self) -> NetAdapterConfig
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more