fidl_next::protocol

Trait Transport

Source
pub trait Transport: 'static {
    type Error: Error + Send + Sync + 'static;
    type Sender: Send;
    type SendBuffer: Send;
    type Encoder<'b>: Encoder + Send
       where Self: 'b;
    type SendFuture<'s>: Future<Output = Result<(), Self::Error>> + Send
       where Self: 's;
    type Receiver: Send;
    type RecvFuture<'r>: Future<Output = Result<Option<Self::RecvBuffer>, Self::Error>> + Send
       where Self: 'r;
    type RecvBuffer: Send;
    type Decoder<'b>: Decoder<'b> + Send
       where Self: 'b;

    // Required methods
    fn split(self) -> (Self::Sender, Self::Receiver);
    fn acquire(sender: &Self::Sender) -> Self::SendBuffer;
    fn encoder(buffer: &mut Self::SendBuffer) -> Self::Encoder<'_>;
    fn send(
        sender: &Self::Sender,
        buffer: Self::SendBuffer,
    ) -> Self::SendFuture<'_>;
    fn recv(receiver: &mut Self::Receiver) -> Self::RecvFuture<'_>;
    fn decoder(buffer: &mut Self::RecvBuffer) -> Self::Decoder<'_>;
}
Expand description

A transport layer which can send and receive messages.

The futures provided by this trait should be cancel-safe, which constrains their behavior:

  • Operations should not partially complete.
  • Operations should only complete during polling.

Required Associated Types§

Source

type Error: Error + Send + Sync + 'static

The error type for the transport.

Source

type Sender: Send

The sender half of the transport.

Source

type SendBuffer: Send

The buffer type for senders.

Source

type Encoder<'b>: Encoder + Send where Self: 'b

The encoder for send buffers.

Source

type SendFuture<'s>: Future<Output = Result<(), Self::Error>> + Send where Self: 's

The future type for send operations.

Source

type Receiver: Send

The receiver half of the transport.

Source

type RecvFuture<'r>: Future<Output = Result<Option<Self::RecvBuffer>, Self::Error>> + Send where Self: 'r

The future type for receive operations.

Source

type RecvBuffer: Send

The buffer type for receivers.

Source

type Decoder<'b>: Decoder<'b> + Send where Self: 'b

The decoder for receive buffers.

Required Methods§

Source

fn split(self) -> (Self::Sender, Self::Receiver)

Splits the transport into a sender and receiver.

Source

fn acquire(sender: &Self::Sender) -> Self::SendBuffer

Acquires an empty send buffer for the transport.

Source

fn encoder(buffer: &mut Self::SendBuffer) -> Self::Encoder<'_>

Gets the encoder for a buffer.

Source

fn send(sender: &Self::Sender, buffer: Self::SendBuffer) -> Self::SendFuture<'_>

Sends an encoded message over the transport.

Source

fn recv(receiver: &mut Self::Receiver) -> Self::RecvFuture<'_>

Receives an encoded message over the transport.

Source

fn decoder(buffer: &mut Self::RecvBuffer) -> Self::Decoder<'_>

Gets the decoder for a buffer.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementations on Foreign Types§

Source§

impl Transport for Channel

Source§

type Error = Status

Source§

type Sender = Sender

Source§

type SendBuffer = Buffer

Source§

type Encoder<'b> = &'b mut Buffer

Source§

type SendFuture<'s> = SendFuture<'s>

Source§

type Receiver = Receiver

Source§

type RecvFuture<'r> = RecvFuture<'r>

Source§

type RecvBuffer = RecvBuffer

Source§

type Decoder<'b> = &'b mut RecvBuffer

Source§

fn split(self) -> (Self::Sender, Self::Receiver)

Source§

fn acquire(_: &Self::Sender) -> Self::SendBuffer

Source§

fn encoder(buffer: &mut Self::SendBuffer) -> Self::Encoder<'_>

Source§

fn send(sender: &Self::Sender, buffer: Self::SendBuffer) -> Self::SendFuture<'_>

Source§

fn recv(receiver: &mut Self::Receiver) -> Self::RecvFuture<'_>

Source§

fn decoder(buffer: &mut Self::RecvBuffer) -> Self::Decoder<'_>

Implementors§