Connection

Trait Connection 

Source
pub trait Connection:
    Send
    + Sync
    + 'static {
    type SendStream: SendStream;
    type RecvStream: RecvStream;
    type OpenError: Error + Send + Sync + 'static;
    type AcceptError: Error + Send + Sync + 'static;

    // Required methods
    fn open_bi(
        &self,
    ) -> impl Future<Output = Result<(Self::SendStream, Self::RecvStream), Self::OpenError>> + Send;
    fn accept_bi(
        &self,
    ) -> impl Future<Output = Result<Option<(Self::SendStream, Self::RecvStream)>, Self::AcceptError>> + Send;
    fn close(&self, code: u32, reason: &[u8]);
    fn is_open(&self) -> bool;
}
Expand description

Abstraction over a QUIC connection.

This trait provides the minimal interface needed by quic-reverse to open and accept bidirectional streams.

Required Associated Types§

Source

type SendStream: SendStream

The send stream type produced by this connection.

Source

type RecvStream: RecvStream

The receive stream type produced by this connection.

Source

type OpenError: Error + Send + Sync + 'static

Error type for opening streams.

Source

type AcceptError: Error + Send + Sync + 'static

Error type for accepting streams.

Required Methods§

Source

fn open_bi( &self, ) -> impl Future<Output = Result<(Self::SendStream, Self::RecvStream), Self::OpenError>> + Send

Opens a new bidirectional stream.

Returns a future that resolves to a send/receive stream pair.

Source

fn accept_bi( &self, ) -> impl Future<Output = Result<Option<(Self::SendStream, Self::RecvStream)>, Self::AcceptError>> + Send

Accepts an incoming bidirectional stream.

Returns a future that resolves to a send/receive stream pair, or None if the connection is closing.

Source

fn close(&self, code: u32, reason: &[u8])

Closes the connection with an error code and reason.

Source

fn is_open(&self) -> bool

Returns true if the connection is still open.

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.

Implementors§