pub enum TransportHandle {
Udp(UdpTransport),
Ethernet(EthernetTransport),
Tcp(TcpTransport),
Tor(TorTransport),
Ble(DefaultBleTransport),
}Expand description
Wrapper enum for concrete transport implementations.
This enables polymorphic transport handling without trait objects, supporting async methods that the sync Transport trait cannot express.
Variants§
Udp(UdpTransport)
UDP/IP transport.
Ethernet(EthernetTransport)
Raw Ethernet transport.
Tcp(TcpTransport)
TCP/IP transport.
Tor(TorTransport)
Tor transport (via SOCKS5).
Ble(DefaultBleTransport)
BLE L2CAP transport.
Implementations§
Source§impl TransportHandle
impl TransportHandle
Sourcepub async fn start(&mut self) -> Result<(), TransportError>
pub async fn start(&mut self) -> Result<(), TransportError>
Start the transport asynchronously.
Sourcepub async fn stop(&mut self) -> Result<(), TransportError>
pub async fn stop(&mut self) -> Result<(), TransportError>
Stop the transport asynchronously.
Sourcepub async fn send(
&self,
addr: &TransportAddr,
data: &[u8],
) -> Result<usize, TransportError>
pub async fn send( &self, addr: &TransportAddr, data: &[u8], ) -> Result<usize, TransportError>
Send data to a remote address asynchronously.
Sourcepub async fn flush_pending_send(&self)
pub async fn flush_pending_send(&self)
Flush any pending outbound batch buffered by the transport.
Called by the rx_loop at end-of-drain so that trailing packets
of a burst don’t sit in the buffer waiting for the threshold.
Only the UDP transport batches today (via sendmmsg(2)); other
transports treat this as a no-op.
Sourcepub fn transport_id(&self) -> TransportId
pub fn transport_id(&self) -> TransportId
Get the transport ID.
Sourcepub fn transport_type(&self) -> &TransportType
pub fn transport_type(&self) -> &TransportType
Get the transport type metadata.
Sourcepub fn state(&self) -> TransportState
pub fn state(&self) -> TransportState
Get current transport state.
Sourcepub fn link_mtu(&self, addr: &TransportAddr) -> u16
pub fn link_mtu(&self, addr: &TransportAddr) -> u16
Get the MTU for a specific link address.
Falls back to transport-wide MTU if the transport doesn’t support per-link MTU or the address is unknown.
Sourcepub fn local_addr(&self) -> Option<SocketAddr>
pub fn local_addr(&self) -> Option<SocketAddr>
Get the local bound address (UDP/TCP only, returns None for other transports).
Sourcepub fn interface_name(&self) -> Option<&str>
pub fn interface_name(&self) -> Option<&str>
Get the interface name (Ethernet only, returns None for other transports).
Sourcepub fn onion_address(&self) -> Option<&str>
pub fn onion_address(&self) -> Option<&str>
Get the onion service address (Tor only, returns None for other transports).
Sourcepub fn tor_monitoring(&self) -> Option<TorMonitoringInfo>
pub fn tor_monitoring(&self) -> Option<TorMonitoringInfo>
Get cached Tor daemon monitoring info (Tor only).
Sourcepub fn discover(&self) -> Result<Vec<DiscoveredPeer>, TransportError>
pub fn discover(&self) -> Result<Vec<DiscoveredPeer>, TransportError>
Drain discovered peers from this transport.
Sourcepub fn auto_connect(&self) -> bool
pub fn auto_connect(&self) -> bool
Whether this transport auto-connects to discovered peers.
Sourcepub fn accept_connections(&self) -> bool
pub fn accept_connections(&self) -> bool
Whether this transport accepts inbound connections.
Sourcepub async fn connect(&self, addr: &TransportAddr) -> Result<(), TransportError>
pub async fn connect(&self, addr: &TransportAddr) -> Result<(), TransportError>
Initiate a non-blocking connection to a remote address.
For connection-oriented transports (TCP, Tor), spawns a background task to establish the connection. For connectionless transports (UDP, Ethernet), this is a no-op that returns Ok immediately.
Poll connection_state() to check when the connection is ready.
Sourcepub fn connection_state(&self, addr: &TransportAddr) -> ConnectionState
pub fn connection_state(&self, addr: &TransportAddr) -> ConnectionState
Query the state of a connection attempt to a remote address.
For connectionless transports, always returns ConnectionState::Connected
(they are always “connected”). For connection-oriented transports, returns
the current state of the background connection attempt.
Sourcepub async fn close_connection(&self, addr: &TransportAddr)
pub async fn close_connection(&self, addr: &TransportAddr)
Close a specific connection on this transport.
No-op for connectionless transports. For TCP/Tor, removes the connection from the pool and drops the stream.
Sourcepub fn is_operational(&self) -> bool
pub fn is_operational(&self) -> bool
Check if transport is operational.
Sourcepub fn congestion(&self) -> TransportCongestion
pub fn congestion(&self) -> TransportCongestion
Query transport-local congestion indicators.
Returns a snapshot of congestion signals that the transport can
observe locally (e.g., kernel receive buffer drops). Fields are
None when the transport doesn’t support that signal.
Sourcepub fn transport_stats(&self) -> Value
pub fn transport_stats(&self) -> Value
Get transport-specific stats as a JSON value.
Returns a snapshot of counters for the specific transport type.
Auto Trait Implementations§
impl !Freeze for TransportHandle
impl !RefUnwindSafe for TransportHandle
impl Send for TransportHandle
impl Sync for TransportHandle
impl Unpin for TransportHandle
impl UnsafeUnpin for TransportHandle
impl !UnwindSafe for TransportHandle
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
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more