pub trait Transport {
// Required methods
fn transport_id(&self) -> TransportId;
fn transport_type(&self) -> &TransportType;
fn state(&self) -> TransportState;
fn mtu(&self) -> u16;
fn start(&mut self) -> Result<(), TransportError>;
fn stop(&mut self) -> Result<(), TransportError>;
fn send(
&self,
addr: &TransportAddr,
data: &[u8],
) -> Result<(), TransportError>;
fn discover(&self) -> Result<Vec<DiscoveredPeer>, TransportError>;
// Provided methods
fn link_mtu(&self, addr: &TransportAddr) -> u16 { ... }
fn auto_connect(&self) -> bool { ... }
fn accept_connections(&self) -> bool { ... }
fn close_connection(&self, _addr: &TransportAddr) { ... }
}Expand description
Transport trait defining the interface for transport drivers.
This is a simplified synchronous trait. Actual implementations would be async and use channels for event delivery.
Required Methods§
Sourcefn transport_id(&self) -> TransportId
fn transport_id(&self) -> TransportId
Get the transport identifier.
Sourcefn transport_type(&self) -> &TransportType
fn transport_type(&self) -> &TransportType
Get the transport type metadata.
Sourcefn state(&self) -> TransportState
fn state(&self) -> TransportState
Get the current state.
Sourcefn start(&mut self) -> Result<(), TransportError>
fn start(&mut self) -> Result<(), TransportError>
Start the transport.
Sourcefn stop(&mut self) -> Result<(), TransportError>
fn stop(&mut self) -> Result<(), TransportError>
Stop the transport.
Sourcefn send(&self, addr: &TransportAddr, data: &[u8]) -> Result<(), TransportError>
fn send(&self, addr: &TransportAddr, data: &[u8]) -> Result<(), TransportError>
Send data to a transport address.
Sourcefn discover(&self) -> Result<Vec<DiscoveredPeer>, TransportError>
fn discover(&self) -> Result<Vec<DiscoveredPeer>, TransportError>
Discover potential peers (if supported).
Provided Methods§
Sourcefn link_mtu(&self, addr: &TransportAddr) -> u16
fn link_mtu(&self, addr: &TransportAddr) -> u16
Get the MTU for a specific link.
Returns the MTU negotiated for the given transport address, or falls back to the transport-wide default if the address is unknown or the transport doesn’t support per-link MTU negotiation.
Sourcefn auto_connect(&self) -> bool
fn auto_connect(&self) -> bool
Whether to auto-connect to peers returned by discover(). Default: false. Concrete transports read from their own config.
Sourcefn accept_connections(&self) -> bool
fn accept_connections(&self) -> bool
Whether to accept inbound handshake initiations on this transport. Default: true (preserves UDP’s current implicit behavior).
Sourcefn close_connection(&self, _addr: &TransportAddr)
fn close_connection(&self, _addr: &TransportAddr)
Close a specific connection (connection-oriented transports only).
For connectionless transports (UDP, Ethernet), this is a no-op. Connection-oriented transports (TCP, Tor) remove the connection from their pool and drop the underlying stream.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".