Struct quinn::generic::Connection [−][src]
A QUIC connection.
If all references to a connection (including every clone of the Connection
handle, streams of
incoming streams, and the various stream types) have been dropped, then the connection will be
automatically closed with an error_code
of 0 and an empty reason
. You can also close the
connection explicitly by calling Connection::close()
.
May be cloned to obtain another handle to the same connection.
Implementations
impl<S> Connection<S> where
S: Session,
[src]
S: Session,
pub fn open_uni(&self) -> OpenUni<S>ⓘNotable traits for OpenUni<S>
impl<S> Future for OpenUni<S> where
S: Session, type Output = Result<SendStream<S>, ConnectionError>;
[src]
Notable traits for OpenUni<S>
impl<S> Future for OpenUni<S> where
S: Session, type Output = Result<SendStream<S>, ConnectionError>;
Initiate a new outgoing unidirectional stream.
Streams are cheap and instantaneous to open unless blocked by flow control. As a consequence, the peer won’t be notified that a stream has been opened until the stream is actually used.
pub fn open_bi(&self) -> OpenBi<S>ⓘNotable traits for OpenBi<S>
impl<S> Future for OpenBi<S> where
S: Session, type Output = Result<(SendStream<S>, RecvStream<S>), ConnectionError>;
[src]
Notable traits for OpenBi<S>
impl<S> Future for OpenBi<S> where
S: Session, type Output = Result<(SendStream<S>, RecvStream<S>), ConnectionError>;
Initiate a new outgoing bidirectional stream.
Streams are cheap and instantaneous to open unless blocked by flow control. As a consequence, the peer won’t be notified that a stream has been opened until the stream is actually used.
pub fn close(&self, error_code: VarInt, reason: &[u8])
[src]
Close the connection immediately.
Pending operations will fail immediately with ConnectionError::LocallyClosed
. Delivery
of data on unfinished streams is not guaranteed, so the application must call this only
when all important communications have been completed, e.g. by calling finish
on
outstanding SendStream
s and waiting for the resulting futures to complete.
error_code
and reason
are not interpreted, and are provided directly to the peer.
reason
will be truncated to fit in a single packet with overhead; to improve odds that it
is preserved in full, it should be kept under 1KiB.
pub fn send_datagram(&self, data: Bytes) -> Result<(), SendDatagramError>
[src]
Transmit data
as an unreliable, unordered application datagram
Application datagrams are a low-level primitive. They may be lost or delivered out of order,
and data
must both fit inside a single QUIC packet and be smaller than the maximum
dictated by the peer.
pub fn max_datagram_size(&self) -> Option<usize>
[src]
Compute 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.
pub fn remote_address(&self) -> SocketAddr
[src]
The peer’s UDP address
If ServerConfig::migration
is true
, clients may change addresses at will, e.g. when
switching to a cellular internet connection.
pub fn local_ip(&self) -> Option<IpAddr>
[src]
The local IP address which was used when the peer established the connection
This can be different from the address the endpoint is bound to, in case
the endpoint is bound to a wildcard address like 0.0.0.0
or ::
.
This will return None
for clients.
Retrieving the local IP address is currently supported on the following platforms:
- Linux
On all non-supported platforms the local IP address will not be available,
and the method will return None
.
pub fn rtt(&self) -> Duration
[src]
Current best estimate of this connection’s latency (round-trip-time)
pub fn stats(&self) -> ConnectionStats
[src]
Returns connection statistics
pub fn handshake_data(&self) -> Option<S::HandshakeData>
[src]
Parameters negotiated during the handshake
Guaranteed to return Some
on fully established connections or after
Connecting::handshake_data()
succeeds.
pub fn peer_identity(&self) -> Option<S::Identity>
[src]
Cryptographic identity of the peer
pub fn stable_id(&self) -> usize
[src]
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.
pub fn export_keying_material(
&self,
output: &mut [u8],
label: &[u8],
context: &[u8]
) -> Result<(), ExportKeyingMaterialError>
[src]
&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.
Trait Implementations
impl<S> Clone for Connection<S> where
S: Session,
[src]
S: Session,
fn clone(&self) -> Self
[src]
pub fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl<S: Debug + Session> Debug for Connection<S>
[src]
Auto Trait Implementations
impl<S> RefUnwindSafe for Connection<S>
impl<S> Send for Connection<S>
impl<S> Sync for Connection<S>
impl<S> Unpin for Connection<S>
impl<S> UnwindSafe for Connection<S>
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T> Instrument for T
[src]
pub fn instrument(self, span: Span) -> Instrumented<Self>
[src]
pub fn in_current_span(self) -> Instrumented<Self>
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
pub fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,