pub trait Connection: Send {
// Required methods
fn send(&mut self, payload: &[u8]) -> Result<(), TransportError>;
fn recv(
&mut self,
timeout: Option<Duration>,
) -> Result<Vec<u8>, TransportError>;
fn close(&mut self) -> Result<(), TransportError>;
// Provided methods
fn supports_sidecars(&self) -> bool { ... }
fn send_sidecar(&mut self, payload: &[u8]) -> Result<(), TransportError> { ... }
fn recv_any(
&mut self,
timeout: Option<Duration>,
) -> Result<Vec<u8>, TransportError> { ... }
}Expand description
A persistent, bidirectional connection to a remote node.
Required Methods§
Sourcefn send(&mut self, payload: &[u8]) -> Result<(), TransportError>
fn send(&mut self, payload: &[u8]) -> Result<(), TransportError>
Send a framed payload over the connection.
Sourcefn recv(&mut self, timeout: Option<Duration>) -> Result<Vec<u8>, TransportError>
fn recv(&mut self, timeout: Option<Duration>) -> Result<Vec<u8>, TransportError>
Receive a framed payload. If timeout is None, blocks indefinitely.
Sourcefn close(&mut self) -> Result<(), TransportError>
fn close(&mut self) -> Result<(), TransportError>
Close the connection gracefully.
Provided Methods§
Sourcefn supports_sidecars(&self) -> bool
fn supports_sidecars(&self) -> bool
Whether this connection supports out-of-band sidecar delivery.
When true, sidecars can be sent in parallel on separate streams
(e.g. QUIC unidirectional streams). When false, sidecars are sent
sequentially on the same connection via send().
Sourcefn send_sidecar(&mut self, payload: &[u8]) -> Result<(), TransportError>
fn send_sidecar(&mut self, payload: &[u8]) -> Result<(), TransportError>
Send a sidecar payload. Default: falls back to send().