pub struct Connection { /* private fields */ }
Expand description
Used to create grouped sub-streams.
Connections can have sub-connections. Streams created via
Connection::byte_stream
and Connection::stream
are tied to their
connection. Streams created with the same Id
but for different
connections will not conflict with each other.
Implementations§
Source§impl Connection
impl Connection
pub fn new(quic_conn: Connection) -> (Self, StreamManager)
Sourcepub fn sub_connection(&mut self) -> Self
pub fn sub_connection(&mut self) -> Self
Create a sub-connection. The n’th call to sub_connection
is paired with the n’th call to sub_connection
on the corresponding
Connection
of the other party. Creating a sub-connection results
in no immediate communication and is a fast synchronous operation.
Sourcepub async fn byte_stream(
&mut self,
) -> Result<(SendStreamBytes, ReceiveStreamBytes), ConnectionError>
pub async fn byte_stream( &mut self, ) -> Result<(SendStreamBytes, ReceiveStreamBytes), ConnectionError>
Establish a byte stream over this connection with the provided Id.
Sourcepub async fn byte_stream_with_id(
&self,
id: Id,
) -> Result<(SendStreamBytes, ReceiveStreamBytes), ConnectionError>
pub async fn byte_stream_with_id( &self, id: Id, ) -> Result<(SendStreamBytes, ReceiveStreamBytes), ConnectionError>
Establish a byte stream over this connection with the provided Id.
Sourcepub async fn stream<T: Serialize + DeserializeOwned>(
&mut self,
) -> Result<(SendStream<T>, ReceiveStream<T>), ConnectionError>
pub async fn stream<T: Serialize + DeserializeOwned>( &mut self, ) -> Result<(SendStream<T>, ReceiveStream<T>), ConnectionError>
Establish a typed stream over this connection.
Sourcepub async fn stream_with_id<T: Serialize + DeserializeOwned>(
&self,
id: Id,
) -> Result<(SendStream<T>, ReceiveStream<T>), ConnectionError>
pub async fn stream_with_id<T: Serialize + DeserializeOwned>( &self, id: Id, ) -> Result<(SendStream<T>, ReceiveStream<T>), ConnectionError>
Establish a typed stream over this connection with the provided explicit Id.
Sourcepub async fn request_response_stream<T: Serialize, S: DeserializeOwned>(
&mut self,
) -> Result<(SendStream<T>, ReceiveStream<S>), ConnectionError>
pub async fn request_response_stream<T: Serialize, S: DeserializeOwned>( &mut self, ) -> Result<(SendStream<T>, ReceiveStream<S>), ConnectionError>
Establish a typed request-response stream over this connection with differing types for the request and response.
Sourcepub async fn request_response_stream_with_id<T: Serialize, S: DeserializeOwned>(
&self,
id: Id,
) -> Result<(SendStream<T>, ReceiveStream<S>), ConnectionError>
pub async fn request_response_stream_with_id<T: Serialize, S: DeserializeOwned>( &self, id: Id, ) -> Result<(SendStream<T>, ReceiveStream<S>), ConnectionError>
Establish a typed request-response stream over this connection with differing types for the request and response.