pub struct QuicServer { /* private fields */ }
Expand description
The quic server that can accept incoming connections.
To create a server, you need to use the QuicServerBuilder
to configure the server, and then call the
QuicServerBuilder::listen
method to start the server.
QuicServer
is unique, which means that there can be only one server running at the same time. If you want to
start a new server, you need to drop the old server first.
QuicServer
can only accept connections, dont manage the connections. You can get the incoming connection by
calling the QuicServer::accept
method.
Implementations§
Source§impl QuicServer
impl QuicServer
Sourcepub fn add_interface(&self, iface: Arc<dyn QuicInterface>) -> Result<()>
pub fn add_interface(&self, iface: Arc<dyn QuicInterface>) -> Result<()>
Bind to an interface.
The server will receive datagrams from it, and prevent the interfaces from being automatically released.
This method can be called after the server shutdown, but the server will still not accept new connections.
Sourcepub fn builder() -> QuicServerBuilder<ConfigBuilder<ServerConfig, WantsVerifier>>
pub fn builder() -> QuicServerBuilder<ConfigBuilder<ServerConfig, WantsVerifier>>
Start to build a QuicServer.
Sourcepub fn builder_with_tls(
tls_config: TlsServerConfig,
) -> QuicServerBuilder<TlsServerConfig>
pub fn builder_with_tls( tls_config: TlsServerConfig, ) -> QuicServerBuilder<TlsServerConfig>
Start to build a QuicServer with the given TLS configuration.
This is useful when you want to customize the TLS configuration, or integrate qm-quic with other crates.
Sourcepub fn builder_with_crypto_provieder(
provider: Arc<CryptoProvider>,
) -> QuicServerBuilder<ConfigBuilder<ServerConfig, WantsVerifier>>
pub fn builder_with_crypto_provieder( provider: Arc<CryptoProvider>, ) -> QuicServerBuilder<ConfigBuilder<ServerConfig, WantsVerifier>>
Start to build a QuicServer with the given tls crypto provider.
Sourcepub fn addresses(&self) -> HashSet<SocketAddr>
pub fn addresses(&self) -> HashSet<SocketAddr>
Get the addresses that the server still listens to.
The return vector may be different from the addresses you passed to the QuicServerBuilder::listen
method.
Sourcepub async fn accept(&self) -> Result<(Arc<Connection>, Pathway)>
pub async fn accept(&self) -> Result<(Arc<Connection>, Pathway)>
Accept the next incoming connection.
The connection accepted may still in the progress of handshake, but you can use it to do anything you want, such as sending data, receiving data… operations will be pending until the connection is connected or closed.
If all listening udp sockets are closed, this method will return an error.