pub trait Conn: Send + Sync {
// Required methods
fn subprotocol(&self) -> Option<&str>;
fn read<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<Vec<u8>, Error>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn write<'life0, 'life1, 'async_trait>(
&'life0 self,
payload: &'life1 [u8],
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
fn close<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
// Provided method
fn close_with_status<'life0, 'life1, 'async_trait>(
&'life0 self,
code: u16,
reason: &'life1 str,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait { ... }
}Expand description
One live connection. The client reads from one task and writes from another, one write
at a time, and may call close concurrently with either. Closing has to
interrupt a read in flight so the reader learns the connection is gone.
Required Methods§
Sourcefn subprotocol(&self) -> Option<&str>
fn subprotocol(&self) -> Option<&str>
What the server negotiated, None if it named nothing.
Sourcefn read<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<Vec<u8>, Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn read<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<Vec<u8>, Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
The next complete message. Fails once the connection is unusable, including after
close.
Provided Methods§
Sourcefn close_with_status<'life0, 'life1, 'async_trait>(
&'life0 self,
code: u16,
reason: &'life1 str,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn close_with_status<'life0, 'life1, 'async_trait>(
&'life0 self,
code: u16,
reason: &'life1 str,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Hangs up with a code and reason of the caller’s choosing, for a caller with
something to tell the server. Where the Go client asks whether a connection also
implements StatusCloser, a Rust caller can always call this: the default forwards
to close, so a transport whose library can’t say why hangs up all
the same. The built-in transport sends the code and as much of the reason as a
control frame has room for.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".