pub trait TransportHandle: Send + Sync {
// Required methods
fn send_unreliable(
&self,
endpoint: &Endpoint,
payload: &[u8],
) -> Result<(), MessagingError>;
fn send_reliable(
&self,
endpoint: &Endpoint,
payload: &[u8],
) -> Result<(), MessagingError>;
fn register(
&self,
token: UID,
receiver: Arc<dyn MessageReceiver>,
) -> Endpoint;
fn unregister(&self, token: &UID) -> Option<Arc<dyn MessageReceiver>>;
fn register_pending_reply(
&self,
addr: &str,
token: UID,
closer: Weak<dyn ReplyQueueCloser>,
);
fn failure_monitor(&self) -> Arc<FailureMonitor> ⓘ;
fn local_address(&self) -> &NetworkAddress;
fn allocate_interface_token(&self) -> UID;
fn random_uid(&self) -> UID;
fn is_local_address(&self, address: &NetworkAddress) -> bool;
fn weak_for_cleanup(&self) -> Weak<dyn TransportHandle>;
}Expand description
Object-safe transport abstraction that erases provider generics.
NetTransport<P> implements this trait, allowing user-facing types
to hold Arc<dyn TransportHandle> without naming P.
Required Methods§
Sourcefn send_unreliable(
&self,
endpoint: &Endpoint,
payload: &[u8],
) -> Result<(), MessagingError>
fn send_unreliable( &self, endpoint: &Endpoint, payload: &[u8], ) -> Result<(), MessagingError>
Send payload unreliably (best-effort, dropped on failure).
§Errors
Returns MessagingError if the endpoint is unknown, the peer rejects
the packet, or transport-level send fails.
Sourcefn send_reliable(
&self,
endpoint: &Endpoint,
payload: &[u8],
) -> Result<(), MessagingError>
fn send_reliable( &self, endpoint: &Endpoint, payload: &[u8], ) -> Result<(), MessagingError>
Send payload reliably (queued, retried on reconnect).
§Errors
Returns MessagingError if the endpoint is unknown, the peer rejects
the packet, or transport-level send fails.
Sourcefn register(&self, token: UID, receiver: Arc<dyn MessageReceiver>) -> Endpoint
fn register(&self, token: UID, receiver: Arc<dyn MessageReceiver>) -> Endpoint
Register a dynamic endpoint receiver, returning the endpoint.
Sourcefn unregister(&self, token: &UID) -> Option<Arc<dyn MessageReceiver>>
fn unregister(&self, token: &UID) -> Option<Arc<dyn MessageReceiver>>
Unregister a dynamic endpoint.
Sourcefn register_pending_reply(
&self,
addr: &str,
token: UID,
closer: Weak<dyn ReplyQueueCloser>,
)
fn register_pending_reply( &self, addr: &str, token: UID, closer: Weak<dyn ReplyQueueCloser>, )
Track a pending reply queue for disconnect cleanup.
Sourcefn failure_monitor(&self) -> Arc<FailureMonitor> ⓘ
fn failure_monitor(&self) -> Arc<FailureMonitor> ⓘ
Get the failure monitor.
Sourcefn local_address(&self) -> &NetworkAddress
fn local_address(&self) -> &NetworkAddress
Get the local address of this transport.
Sourcefn allocate_interface_token(&self) -> UID
fn allocate_interface_token(&self) -> UID
Allocate a random base token for a dynamic interface.
Sourcefn random_uid(&self) -> UID
fn random_uid(&self) -> UID
Generate a random UID (for reply endpoints, etc.).
Sourcefn is_local_address(&self, address: &NetworkAddress) -> bool
fn is_local_address(&self, address: &NetworkAddress) -> bool
Check if an address is local to this transport.
Sourcefn weak_for_cleanup(&self) -> Weak<dyn TransportHandle>
fn weak_for_cleanup(&self) -> Weak<dyn TransportHandle>
Get a weak reference for drop cleanup callbacks.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".