pub trait ConfigExt<ServerType, AcceptorType>
where ServerType: Server,
{ // Required methods fn port(&self) -> u16; fn host(&self) -> String; fn socket_addrs(&self) -> Vec<SocketAddr>; fn should_register_signals(&self) -> bool; fn nodelay(&self) -> bool; fn stopper(&self) -> Stopper; fn acceptor(&self) -> &AcceptorType; fn counter_observer(&self) -> &CloneCounterObserver; fn graceful_shutdown<'async_trait>( self ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>> where Self: 'async_trait; fn handle_stream<'async_trait>( self, stream: ServerType::Transport, handler: impl 'async_trait + Handler ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>> where Self: 'async_trait; fn build_listener<Listener>(&self) -> Listener where Listener: TryFrom<TcpListener>, <Listener as TryFrom<TcpListener>>::Error: Debug; fn over_capacity(&self) -> bool; }
Expand description

Server-implementer interfaces to Config

These functions are intended for use by authors of trillium servers, and should not be necessary to build an application. Please open an issue if you find yourself using this trait directly in an application.

Required Methods§

source

fn port(&self) -> u16

resolve a port for this application, either directly configured, from the environmental variable PORT, or a default of 8080

source

fn host(&self) -> String

resolve the host for this application, either directly from configuration, from the HOST env var, or "localhost"

source

fn socket_addrs(&self) -> Vec<SocketAddr>

use the ConfigExt::port and ConfigExt::host to resolve a vec of potential socket addrs

source

fn should_register_signals(&self) -> bool

returns whether this server should register itself for operating system signals. this flag does nothing aside from communicating to the server implementer that this is desired. defaults to true on cfg(unix) systems, and false elsewhere.

source

fn nodelay(&self) -> bool

returns whether the server should set TCP_NODELAY on the TcpListener, if that is applicable

source

fn stopper(&self) -> Stopper

returns a clone of the Stopper associated with this server, to be used in conjunction with signals or other service interruption methods

source

fn acceptor(&self) -> &AcceptorType

returns the tls acceptor for this server

source

fn counter_observer(&self) -> &CloneCounterObserver

returns the CloneCounterObserver for this server

source

fn graceful_shutdown<'async_trait>( self ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
where Self: 'async_trait,

waits for the last clone of the CloneCounter in this config to drop, indicating that all outstanding requests are complete

source

fn handle_stream<'async_trait>( self, stream: ServerType::Transport, handler: impl 'async_trait + Handler ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
where Self: 'async_trait,

apply the provided handler to the transport, using [trillium_http]’s http implementation. this is the default inner loop for most trillium servers

source

fn build_listener<Listener>(&self) -> Listener
where Listener: TryFrom<TcpListener>, <Listener as TryFrom<TcpListener>>::Error: Debug,

builds any type that is TryFromstd::net::TcpListener and configures it for use. most trillium servers should use this if possible instead of using ConfigExt::port, ConfigExt::host, or ConfigExt::socket_addrs.

this function also contains logic that sets nonblocking to true and on unix systems will build a tcp listener from the LISTEN_FD env var.

source

fn over_capacity(&self) -> bool

determines if the server is currently responding to more than the maximum number of connections set by Config::with_max_connections.

Object Safety§

This trait is not object safe.

Implementors§

source§

impl<ServerType, AcceptorType> ConfigExt<ServerType, AcceptorType> for Config<ServerType, AcceptorType>
where ServerType: Server + Send + ?Sized, AcceptorType: Acceptor<<ServerType as Server>::Transport>,