Skip to main content

TransportHandle

Enum TransportHandle 

Source
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

Source

pub async fn start(&mut self) -> Result<(), TransportError>

Start the transport asynchronously.

Source

pub async fn stop(&mut self) -> Result<(), TransportError>

Stop the transport asynchronously.

Source

pub async fn send( &self, addr: &TransportAddr, data: &[u8], ) -> Result<usize, TransportError>

Send data to a remote address asynchronously.

Source

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.

Source

pub fn transport_id(&self) -> TransportId

Get the transport ID.

Source

pub fn name(&self) -> Option<&str>

Get the instance name (if configured as a named instance).

Source

pub fn transport_type(&self) -> &TransportType

Get the transport type metadata.

Source

pub fn state(&self) -> TransportState

Get current transport state.

Source

pub fn mtu(&self) -> u16

Get the transport MTU.

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.

Source

pub fn local_addr(&self) -> Option<SocketAddr>

Get the local bound address (UDP/TCP only, returns None for other transports).

Source

pub fn interface_name(&self) -> Option<&str>

Get the interface name (Ethernet only, returns None for other transports).

Source

pub fn onion_address(&self) -> Option<&str>

Get the onion service address (Tor only, returns None for other transports).

Source

pub fn tor_monitoring(&self) -> Option<TorMonitoringInfo>

Get cached Tor daemon monitoring info (Tor only).

Source

pub fn tor_mode(&self) -> Option<&str>

Get the Tor transport mode (Tor only).

Source

pub fn discover(&self) -> Result<Vec<DiscoveredPeer>, TransportError>

Drain discovered peers from this transport.

Source

pub fn auto_connect(&self) -> bool

Whether this transport auto-connects to discovered peers.

Source

pub fn accept_connections(&self) -> bool

Whether this transport accepts inbound connections.

Source

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.

Source

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.

Source

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.

Source

pub fn is_operational(&self) -> bool

Check if transport is operational.

Source

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.

Source

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§

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> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
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

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more