pub struct Client(/* private fields */);Expand description
WebTransport wRPC client
Methods from Deref<Target = Connection>§
Sourcepub async fn accept_uni(&self) -> Result<RecvStream, ConnectionError>
pub async fn accept_uni(&self) -> Result<RecvStream, ConnectionError>
Asynchronously accepts a unidirectional stream.
This method is used to accept incoming unidirectional streams that have been initiated
by the remote peer.
It waits for the next unidirectional stream to be available, then wraps it in a
RecvStream that can be used to read data from the stream.
§Cancel safety
This method is cancel safe.
Sourcepub async fn accept_bi(
&self,
) -> Result<(SendStream, RecvStream), ConnectionError>
pub async fn accept_bi( &self, ) -> Result<(SendStream, RecvStream), ConnectionError>
Asynchronously accepts a bidirectional stream.
This method is used to accept incoming bidirectional streams that have been initiated
by the remote peer.
It waits for the next bidirectional stream to be available, then wraps it in a
tuple containing a SendStream for sending data and a RecvStream for receiving
data on the stream.
§Cancel safety
This method is cancel safe.
Sourcepub async fn open_uni(&self) -> Result<OpeningUniStream, ConnectionError>
pub async fn open_uni(&self) -> Result<OpeningUniStream, ConnectionError>
Asynchronously opens a new unidirectional stream.
This method is used to initiate the opening of a new unidirectional stream.
§Asynchronous Behavior
This method is asynchronous and involves two await points:
-
The first
awaitoccurs during the initial phase of opening the stream, which may involve awaiting the flow controller. This wait is necessary to ensure proper resource allocation and flow control. It is safe to cancel thisawaitpoint if needed. -
The second
awaitis internal to the returnedOpeningUniStreamobject when it is used to initialize the WebTransport stream. Cancelling this latter future before it completes may result in the stream being closed during initialization.
§Example
let send_stream = connection.open_uni().await?.await?;Sourcepub async fn open_bi(&self) -> Result<OpeningBiStream, ConnectionError>
pub async fn open_bi(&self) -> Result<OpeningBiStream, ConnectionError>
Asynchronously opens a new bidirectional stream.
This method is used to initiate the opening of a new bidirectional stream.
§Asynchronous Behavior
This method is asynchronous and involves two await points:
-
The first
awaitoccurs during the initial phase of opening the stream, which may involve awaiting the flow controller. This wait is necessary to ensure proper resource allocation and flow control. It is safe to cancel thisawaitpoint if needed. -
The second
awaitis internal to the returnedOpeningBiStreamobject when it is used to initialize the WebTransport stream. Cancelling this latter future before it completes may result in the stream being closed during initialization.
§Example
let (send_stream, recv_stream) = connection.open_bi().await?.await?;Sourcepub async fn receive_datagram(&self) -> Result<Datagram, ConnectionError>
pub async fn receive_datagram(&self) -> Result<Datagram, ConnectionError>
Asynchronously receives an application datagram from the remote peer.
This method is used to receive an application datagram sent by the remote
peer over the connection.
It waits for a datagram to become available and returns the received Datagram.
§Example
let datagram = connection.receive_datagram().await?;Sourcepub fn send_datagram<D>(&self, payload: D) -> Result<(), SendDatagramError>
pub fn send_datagram<D>(&self, payload: D) -> Result<(), SendDatagramError>
Sends an application datagram to the remote peer.
This method is used to send an application datagram to the remote peer over the connection. The datagram payload is provided as a reference to a slice of bytes.
§Example
connection.send_datagram(b"Hello, wtransport!")?;Sourcepub async fn closed(&self) -> ConnectionError
pub async fn closed(&self) -> ConnectionError
Waits for the connection to be closed for any reason.
Sourcepub fn session_id(&self) -> SessionId
pub fn session_id(&self) -> SessionId
Returns the WebTransport session identifier.
Sourcepub fn remote_address(&self) -> SocketAddr
pub fn remote_address(&self) -> SocketAddr
Returns the peer’s UDP address.
Note: as QUIC supports migration, remote address may change during connection. Furthermore, when IPv6 support is enabled, IPv4 addresses may be mapped to IPv6.
Sourcepub fn stable_id(&self) -> usize
pub fn stable_id(&self) -> usize
A stable identifier for this connection.
Peer addresses and connection IDs can change, but this value will remain fixed for the lifetime of the connection.
Sourcepub fn max_datagram_size(&self) -> Option<usize>
pub fn max_datagram_size(&self) -> Option<usize>
Computes the maximum size of datagrams that may be passed to
send_datagram.
Returns None if datagrams are unsupported by the peer or disabled locally.
This may change over the lifetime of a connection according to variation in the path MTU estimate. The peer can also enforce an arbitrarily small fixed limit, but if the peer’s limit is large this is guaranteed to be a little over a kilobyte at minimum.
Not necessarily the maximum size of received datagrams.
Sourcepub fn rtt(&self) -> Duration
pub fn rtt(&self) -> Duration
Current best estimate of this connection’s latency (round-trip-time).
Sourcepub fn export_keying_material(
&self,
output: &mut [u8],
label: &[u8],
context: &[u8],
) -> Result<(), ExportKeyingMaterialError>
pub fn export_keying_material( &self, output: &mut [u8], label: &[u8], context: &[u8], ) -> Result<(), ExportKeyingMaterialError>
Derive keying material from this connection’s TLS session secrets.
When both peers call this method with the same label and context
arguments and output buffers of equal length, they will get the
same sequence of bytes in output. These bytes are cryptographically
strong and pseudorandom, and are suitable for use as keying material.
See RFC5705 for more information.
Sourcepub fn peer_identity(&self) -> Option<CertificateChain>
pub fn peer_identity(&self) -> Option<CertificateChain>
Returns the peer’s identity as a certificate chain if available.
This function returns an Option containing a CertificateChain. If the peer’s identity
is available, it is converted into a CertificateChain and returned. If the peer’s identity
is not available, None is returned.
Sourcepub fn handshake_data(&self) -> HandshakeData
pub fn handshake_data(&self) -> HandshakeData
Retrieves handshake data associated with the connection.
Sourcepub fn quic_connection(&self) -> &Connection
pub fn quic_connection(&self) -> &Connection
Returns a reference to the inner QUIC connection.
Sourcepub fn quic_connection_mut(&mut self) -> &mut Connection
pub fn quic_connection_mut(&mut self) -> &mut Connection
Returns a mutable reference to the inner QUIC connection.
Trait Implementations§
Source§impl Accept for &Client
impl Accept for &Client
Source§type Outgoing = SendStream
type Outgoing = SendStream
Source§type Incoming = RecvStream
type Incoming = RecvStream
Source§impl Accept for Client
impl Accept for Client
Source§type Outgoing = SendStream
type Outgoing = SendStream
Source§type Incoming = RecvStream
type Incoming = RecvStream
Source§impl From<Connection> for Client
impl From<Connection> for Client
Source§fn from(session: Connection) -> Self
fn from(session: Connection) -> Self
Auto Trait Implementations§
impl Freeze for Client
impl !RefUnwindSafe for Client
impl Send for Client
impl Sync for Client
impl Unpin for Client
impl !UnwindSafe for Client
Blanket Implementations§
Source§impl<T> AcceptExt for Twhere
T: Accept,
impl<T> AcceptExt for Twhere
T: Accept,
Source§fn map_context<T, F>(self, f: F) -> AcceptMapContext<Self, F>
fn map_context<T, F>(self, f: F) -> AcceptMapContext<Self, F>
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> InvokeExt for Twhere
T: Invoke,
impl<T> InvokeExt for Twhere
T: Invoke,
Source§fn invoke_values<P, Params, Results>(
&self,
cx: Self::Context,
instance: &str,
func: &str,
params: Params,
paths: impl AsRef<[P]> + Send,
) -> impl Future<Output = Result<(Results, Option<impl Future<Output = Result<(), Error>> + Send + 'static>), Error>> + Sendwhere
P: AsRef<[Option<usize>]> + Send + Sync,
Params: TupleEncode<Self::Outgoing> + Send,
Results: TupleDecode<Self::Incoming> + Send,
<<Params as Encode<Self::Outgoing>>::Encoder as Encoder<Params>>::Error: Error + Send + Sync + 'static,
<<Results as Decode<Self::Incoming>>::Decoder as Decoder>::Error: Error + Send + Sync + 'static,
fn invoke_values<P, Params, Results>(
&self,
cx: Self::Context,
instance: &str,
func: &str,
params: Params,
paths: impl AsRef<[P]> + Send,
) -> impl Future<Output = Result<(Results, Option<impl Future<Output = Result<(), Error>> + Send + 'static>), Error>> + Sendwhere
P: AsRef<[Option<usize>]> + Send + Sync,
Params: TupleEncode<Self::Outgoing> + Send,
Results: TupleDecode<Self::Incoming> + Send,
<<Params as Encode<Self::Outgoing>>::Encoder as Encoder<Params>>::Error: Error + Send + Sync + 'static,
<<Results as Decode<Self::Incoming>>::Decoder as Decoder>::Error: Error + Send + Sync + 'static,
func on instance instance using typed Params and ResultsSource§fn invoke_values_blocking<P, Params, Results>(
&self,
cx: Self::Context,
instance: &str,
func: &str,
params: Params,
paths: impl AsRef<[P]> + Send,
) -> impl Future<Output = Result<Results, Error>> + Sendwhere
P: AsRef<[Option<usize>]> + Send + Sync,
Params: TupleEncode<Self::Outgoing> + Send,
Results: TupleDecode<Self::Incoming> + Send,
<<Params as Encode<Self::Outgoing>>::Encoder as Encoder<Params>>::Error: Error + Send + Sync + 'static,
<<Results as Decode<Self::Incoming>>::Decoder as Decoder>::Error: Error + Send + Sync + 'static,
fn invoke_values_blocking<P, Params, Results>(
&self,
cx: Self::Context,
instance: &str,
func: &str,
params: Params,
paths: impl AsRef<[P]> + Send,
) -> impl Future<Output = Result<Results, Error>> + Sendwhere
P: AsRef<[Option<usize>]> + Send + Sync,
Params: TupleEncode<Self::Outgoing> + Send,
Results: TupleDecode<Self::Incoming> + Send,
<<Params as Encode<Self::Outgoing>>::Encoder as Encoder<Params>>::Error: Error + Send + Sync + 'static,
<<Results as Decode<Self::Incoming>>::Decoder as Decoder>::Error: Error + Send + Sync + 'static,
func on instance instance using typed Params and Results
This is like Self::invoke_values, but it only results once all I/O is doneSource§fn timeout(&self, timeout: Duration) -> Timeout<'_, Self>
fn timeout(&self, timeout: Duration) -> Timeout<'_, Self>
Timeout, wrapping Self with an implementation of Invoke, which will
error, if call to Invoke::invoke does not return within a supplied timeout