Skip to main content

Transport

Trait Transport 

Source
pub trait Transport {
    // Required methods
    fn send(&mut self, message: &[u8]) -> Result<(), TransportError>;
    fn receive(&mut self) -> Result<Vec<u8>, TransportError>;
    fn binding(&self) -> [u8; 32];
    fn own_endpoint(&self) -> [u8; 32];
    fn peer_endpoint(&self) -> [u8; 32];

    // Provided method
    fn has_message(&mut self) -> bool { ... }
}
Expand description

A connection between two replicas, which carries whole messages in order, and is encrypted and bound to the two endpoints’ keys (Sync).

Required Methods§

Source

fn send(&mut self, message: &[u8]) -> Result<(), TransportError>

Sends a message.

§Errors

Returns an error if the connection fails.

Source

fn receive(&mut self) -> Result<Vec<u8>, TransportError>

Waits for the next message.

§Errors

Returns an error if the connection fails or closes, or the message is longer than MAX_MESSAGE_LEN.

Source

fn binding(&self) -> [u8; 32]

The 32 bytes exported from the connection’s encryption, the same on both sides of this connection and on no other.

Source

fn own_endpoint(&self) -> [u8; 32]

This side’s endpoint ID.

Source

fn peer_endpoint(&self) -> [u8; 32]

The other side’s endpoint ID, as the connection proved it.

Provided Methods§

Source

fn has_message(&mut self) -> bool

Whether Transport::receive would return at once: the next message has arrived, or the connection failed. A transport that cannot tell says no, which costs only speed: a replica saves what it received before it waits (Holder::pause).

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§