Trait PlatformOps
pub trait PlatformOps: ProtocolIO {
// Required methods
fn track_client_transport(stream: &Self::Stream, rebinder: &LocalRebinder);
fn p2p_hole_punch<R>(
session: CitadelSession<R, Self>,
peer_connection_type: PeerConnectionType,
ticket: Ticket,
peer_nat_info: PeerNatInfo,
app: NetworkEndpoint,
endpoint_ratchet: R,
peer_cid: u64,
sync_instant: Instant,
node_type: RelativeNodeType,
udp_mode: UdpMode,
session_security_settings: SessionSecuritySettings,
plan: P2pPlan,
) -> impl Future<Output = bool> + ContextRequirements
where R: Ratchet;
// Provided methods
fn identify_nat_type(
stun_servers: Option<Vec<String>>,
) -> impl Future<Output = Result<NatType, Error>> + ContextRequirements { ... }
fn quic_udp_channel(
conn: Connection,
local_addr: SocketAddr,
) -> Option<UdpSplittableTypes> { ... }
fn c2s_hole_punch<R>(
stream: ReliableOrderedCompatStream<R>,
ratchet: R,
security_level: SecurityLevel,
target_cid: u64,
stun_servers: Option<Vec<String>>,
node_type: RelativeNodeType,
) -> impl Future<Output = Result<Option<UdpSplittableTypes>, NetworkError>> + ContextRequirements
where R: Ratchet { ... }
fn open_and_validate_for_transfer(
source_path: &Path,
expected_metadata: Option<&VirtualObjectMetadata>,
) -> Result<TransferMetadata, NetworkError> { ... }
fn ws_pinger(stream: &Self::Stream) -> Option<WsPinger> { ... }
fn spawn_udp_socket_loader<R>(
session: CitadelSession<R, Self>,
v_target: VirtualConnectionType,
udp_conn: UdpSplittableTypes,
addr: TargettedSocketAddr,
ticket: Ticket,
tcp_conn_awaiter: Option<Receiver<()>>,
)
where R: Ratchet { ... }
}Expand description
Platform-specific capabilities extending the transport abstraction.
[ProtocolIO] defines how bytes move on the wire.
PlatformOps defines what the platform can do: NAT traversal, file I/O,
UDP session management, P2P hole punching.
Each platform (NativeIO, WasmIO) provides its own implementation.
Business logic uses T: PlatformOps and calls T::method() directly —
no cfg gates, no dispatch modules.
Required Methods§
fn track_client_transport(stream: &Self::Stream, rebinder: &LocalRebinder)
fn track_client_transport(stream: &Self::Stream, rebinder: &LocalRebinder)
Tracks a client connection’s transport with rebinder if it can move to a new local
address (a QUIC client endpoint). Every platform says what it does: no default.
fn p2p_hole_punch<R>(
session: CitadelSession<R, Self>,
peer_connection_type: PeerConnectionType,
ticket: Ticket,
peer_nat_info: PeerNatInfo,
app: NetworkEndpoint,
endpoint_ratchet: R,
peer_cid: u64,
sync_instant: Instant,
node_type: RelativeNodeType,
udp_mode: UdpMode,
session_security_settings: SessionSecuritySettings,
plan: P2pPlan,
) -> impl Future<Output = bool> + ContextRequirementswhere
R: Ratchet,
fn p2p_hole_punch<R>(
session: CitadelSession<R, Self>,
peer_connection_type: PeerConnectionType,
ticket: Ticket,
peer_nat_info: PeerNatInfo,
app: NetworkEndpoint,
endpoint_ratchet: R,
peer_cid: u64,
sync_instant: Instant,
node_type: RelativeNodeType,
udp_mode: UdpMode,
session_security_settings: SessionSecuritySettings,
plan: P2pPlan,
) -> impl Future<Output = bool> + ContextRequirementswhere
R: Ratchet,
One attempt to move an established peer connection off the server relay: hole punch,
then TURN when the plan allows, attaching the resulting route to the virtual connection.
Resolves to whether a P2P route was attached. The application already holds the channel
(it works over the relay from the start); this runs in the background, inside the
connection’s campaign (p2p_campaign), which cancels it by dropping the future.
app is the endpoint both peers registered over the relay, used to coordinate the punch.
Provided Methods§
fn identify_nat_type(
stun_servers: Option<Vec<String>>,
) -> impl Future<Output = Result<NatType, Error>> + ContextRequirements
fn identify_nat_type( stun_servers: Option<Vec<String>>, ) -> impl Future<Output = Result<NatType, Error>> + ContextRequirements
Identify local NAT type via STUN servers.
Default: returns NatType::offline() (appropriate for WASM).
fn quic_udp_channel(
conn: Connection,
local_addr: SocketAddr,
) -> Option<UdpSplittableTypes>
fn quic_udp_channel( conn: Connection, local_addr: SocketAddr, ) -> Option<UdpSplittableTypes>
Create a UDP channel from an existing QUIC connection.
Default: returns None (QUIC not available).
fn c2s_hole_punch<R>(
stream: ReliableOrderedCompatStream<R>,
ratchet: R,
security_level: SecurityLevel,
target_cid: u64,
stun_servers: Option<Vec<String>>,
node_type: RelativeNodeType,
) -> impl Future<Output = Result<Option<UdpSplittableTypes>, NetworkError>> + ContextRequirementswhere
R: Ratchet,
fn c2s_hole_punch<R>(
stream: ReliableOrderedCompatStream<R>,
ratchet: R,
security_level: SecurityLevel,
target_cid: u64,
stun_servers: Option<Vec<String>>,
node_type: RelativeNodeType,
) -> impl Future<Output = Result<Option<UdpSplittableTypes>, NetworkError>> + ContextRequirementswhere
R: Ratchet,
Perform C2S UDP hole punch via NetworkEndpoint + encrypted hole punch.
Returns the resulting UDP interface, or None if unavailable.
Default: returns Ok(None) (hole punching not available).
fn open_and_validate_for_transfer(
source_path: &Path,
expected_metadata: Option<&VirtualObjectMetadata>,
) -> Result<TransferMetadata, NetworkError>
fn open_and_validate_for_transfer( source_path: &Path, expected_metadata: Option<&VirtualObjectMetadata>, ) -> Result<TransferMetadata, NetworkError>
Open a file and validate it for transfer. Default: returns an error (file transfer not supported).
fn ws_pinger(stream: &Self::Stream) -> Option<WsPinger>
fn ws_pinger(stream: &Self::Stream) -> Option<WsPinger>
The WebSocket pinger of a C2S stream carried by a WebSocket (see misc::ws_ping), taken
before the stream is split. Default: None, a transport with no ping of its own.
fn spawn_udp_socket_loader<R>(
session: CitadelSession<R, Self>,
v_target: VirtualConnectionType,
udp_conn: UdpSplittableTypes,
addr: TargettedSocketAddr,
ticket: Ticket,
tcp_conn_awaiter: Option<Receiver<()>>,
)where
R: Ratchet,
fn spawn_udp_socket_loader<R>(
session: CitadelSession<R, Self>,
v_target: VirtualConnectionType,
udp_conn: UdpSplittableTypes,
addr: TargettedSocketAddr,
ticket: Ticket,
tcp_conn_awaiter: Option<Receiver<()>>,
)where
R: Ratchet,
Spawn the UDP socket loader for a session. On native: spawns an async task for the full UDP subsystem. Default: no-op.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".