[−][src]Struct quinn::Connection
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) other than the ConnectionDriver
have been
dropped, the 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.
Methods
impl Connection
[src]
ⓘImportant traits for OpenUnipub fn open_uni(&self) -> OpenUni
[src]
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.
ⓘImportant traits for OpenBipub fn open_bi(&self) -> OpenBi
[src]
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.
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) -> SendDatagram
[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.
Will not wait unless the link is congested. The first call on a connection after
send_datagram_ready
completes successfully is guaranteed not to wait.
pub fn send_datagram_ready(&self) -> SendDatagramReady
[src]
Wait until the next send_datagram
won't need to wait
Useful when you don't want to materialize a datagram until the last possible moment before sending. Has no impact unless the link is congested.
pub fn max_datagram_size(&self) -> Option<usize>
[src]
Compute the maximum size of datagrams that may 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.
pub fn remote_id(&self) -> ConnectionId
[src]
The ConnectionId
defined for conn
by the peer.
pub fn protocol(&self) -> Option<Box<[u8]>>
[src]
The negotiated application protocol
Trait Implementations
impl Clone for Connection
[src]
fn clone(&self) -> Connection
[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl Debug for Connection
[src]
Auto Trait Implementations
impl Send for Connection
impl Sync for Connection
impl Unpin for Connection
impl UnwindSafe for Connection
impl RefUnwindSafe for Connection
Blanket Implementations
impl<T> From<T> for T
[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.
fn to_owned(&self) -> T
[src]
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 = !
The type returned in the event of a conversion error.
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.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,