[go: up one dir, main page]

Struct quinn::Endpoint

source ·
pub struct Endpoint { /* private fields */ }
Expand description

A QUIC endpoint.

An endpoint corresponds to a single UDP socket, may host many connections, and may act as both client and server for different connections.

May be cloned to obtain another handle to the same endpoint.

Implementations§

Helper to construct an endpoint for use with outgoing connections only

Note that addr is the local address to bind to, which should usually be a wildcard address like 0.0.0.0:0 or [::]:0, which allow communication with any reachable IPv4 or IPv6 address respectively from an OS-assigned port.

Platform defaults for dual-stack sockets vary. For example, any socket bound to a wildcard IPv6 address on Windows will not by default be able to communicate with IPv4 addresses. Portable applications should bind an address that matches the family they wish to communicate within.

Helper to construct an endpoint for use with both incoming and outgoing connections

Platform defaults for dual-stack sockets vary. For example, any socket bound to a wildcard IPv6 address on Windows will not by default be able to communicate with IPv4 addresses. Portable applications should bind an address that matches the family they wish to communicate within.

Construct an endpoint with arbitrary configuration and socket

Construct an endpoint with arbitrary configuration and pre-constructed abstract socket

Useful when socket has additional state (e.g. sidechannels) attached for which shared ownership is needed.

Get the next incoming connection attempt from a client

Yields Connecting futures that must be awaited to obtain the final Connection, or None if the endpoint is closed.

Set the client configuration used by connect

Connect to a remote endpoint

server_name must be covered by the certificate presented by the server. This prevents a connection from being intercepted by an attacker with a valid certificate for some other server.

May fail immediately due to configuration errors, or in the future if the connection could not be established.

Connect to a remote endpoint using a custom configuration.

See connect() for details.

Switch to a new UDP socket

Allows the endpoint’s address to be updated live, affecting all active connections. Incoming connections and connections to servers unreachable from the new address will be lost.

On error, the old UDP socket is retained.

Replace the server configuration, affecting new incoming connections only

Useful for e.g. refreshing TLS certificates without disrupting existing connections.

Get the local SocketAddr the underlying socket is bound to

Close all of this endpoint’s connections immediately and cease accepting new connections.

See Connection::close() for details.

Wait for all connections on the endpoint to be cleanly shut down

Waiting for this condition before exiting ensures that a good-faith effort is made to notify peers of recent connection closes, whereas exiting immediately could force them to wait out the idle timeout period.

Does not proactively close existing connections or cause incoming connections to be rejected. Consider calling close() if that is desired.

Trait Implementations§

Returns a copy of the value. Read more
Performs copy-assignment from source. Read more
Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Instruments this type with the current Span, returning an Instrumented wrapper. Read more

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning. Read more
Uses borrowed data to replace owned data, usually by cloning. Read more
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.
Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more