Skip to main content

TransportHandle

Trait TransportHandle 

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

Source

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.

Source

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.

Source

fn register(&self, token: UID, receiver: Arc<dyn MessageReceiver>) -> Endpoint

Register a dynamic endpoint receiver, returning the endpoint.

Source

fn unregister(&self, token: &UID) -> Option<Arc<dyn MessageReceiver>>

Unregister a dynamic endpoint.

Source

fn register_pending_reply( &self, addr: &str, token: UID, closer: Weak<dyn ReplyQueueCloser>, )

Track a pending reply queue for disconnect cleanup.

Source

fn failure_monitor(&self) -> Arc<FailureMonitor>

Get the failure monitor.

Source

fn local_address(&self) -> &NetworkAddress

Get the local address of this transport.

Source

fn allocate_interface_token(&self) -> UID

Allocate a random base token for a dynamic interface.

Source

fn random_uid(&self) -> UID

Generate a random UID (for reply endpoints, etc.).

Source

fn is_local_address(&self, address: &NetworkAddress) -> bool

Check if an address is local to this transport.

Source

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".

Implementors§

Source§

impl<P, C> TransportHandle for NetTransport<P, C>
where P: Providers + Send + Sync, C: MessageCodec,