Skip to main content

ServerConfig

Struct ServerConfig 

Source
pub struct ServerConfig { /* private fields */ }
Expand description

This struct represents the shared configuration and context for a http server.

This currently contains tunable parameters in a HttpConfig, the Swansong graceful shutdown control interface, and a shared TypeSet that contains application-specific information about the running server

Implementations§

Source§

impl ServerConfig

Source

pub fn http_config(&self) -> &HttpConfig

Borrows HttpConfig performance and security parameters

Source

pub fn http_config_mut(&mut self) -> &mut HttpConfig

Mutably borrow HttpConfig performance and security parameters

Source

pub fn set_http_config(&mut self, http_config: HttpConfig) -> &mut Self

Sets HttpConfig performance and security parameters, returning &mut Self for chaining

Source

pub fn with_http_config(self, http_config: HttpConfig) -> Self

Owned chainable setter for HttpConfig performance and security parameters, returning Self

Source

pub fn swansong(&self) -> &Swansong

Borrows Swansong graceful shutdown interface

Source

pub fn swansong_mut(&mut self) -> &mut Swansong

Mutably borrow Swansong graceful shutdown interface

Source

pub fn set_swansong(&mut self, swansong: Swansong) -> &mut Self

Sets Swansong graceful shutdown interface, returning &mut Self for chaining

Source

pub fn with_swansong(self, swansong: Swansong) -> Self

Owned chainable setter for Swansong graceful shutdown interface, returning Self

Source

pub fn shared_state(&self) -> &TypeSet

Borrows TypeSet shared state

Source

pub fn shared_state_mut(&mut self) -> &mut TypeSet

Mutably borrow TypeSet shared state

Source

pub fn set_shared_state(&mut self, shared_state: TypeSet) -> &mut Self

Sets TypeSet shared state, returning &mut Self for chaining

Source

pub fn with_shared_state(self, shared_state: TypeSet) -> Self

Owned chainable setter for TypeSet shared state, returning Self

Source§

impl ServerConfig

Source

pub fn new() -> Self

Construct a new ServerConfig

Source

pub async fn run<Transport, Handler, Fut>( self: Arc<Self>, transport: Transport, handler: Handler, ) -> Result<Option<Upgrade<Transport>>>
where Transport: AsyncRead + AsyncWrite + Unpin + Send + Sync + 'static, Handler: FnMut(Conn<Transport>) -> Fut, Fut: Future<Output = Conn<Transport>>,

Perform HTTP on the provided transport, applying the provided async Conn -> Conn handler function for every distinct http request-response.

For any given invocation of ServerConfig::run, the handler function may run any number of times, depending on whether the connection is reused by the client.

This can only be called on an Arc<ServerConfig> because an arc clone is moved into the Conn.

§Errors

This function will return an Error if any of the http requests is irrecoverably malformed or otherwise noncompliant.

Source

pub fn shut_down(&self) -> ShutdownCompletion

Attempt graceful shutdown of this server.

The returned ShutdownCompletion type can either be awaited in an async context or blocked on with ShutdownCompletion::block in a blocking context

Trait Implementations§

Source§

impl AsMut<TypeSet> for ServerConfig

Source§

fn as_mut(&mut self) -> &mut TypeSet

Converts this type into a mutable reference of the (usually inferred) input type.
Source§

impl AsRef<HttpConfig> for ServerConfig

Source§

fn as_ref(&self) -> &HttpConfig

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl AsRef<Swansong> for ServerConfig

Source§

fn as_ref(&self) -> &Swansong

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl AsRef<TypeSet> for ServerConfig

Source§

fn as_ref(&self) -> &TypeSet

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl Debug for ServerConfig

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for ServerConfig

Source§

fn default() -> ServerConfig

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

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

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.