http1::server

Struct Server

source
pub struct Server<E = ThreadPool> { /* private fields */ }
Expand description

The server implementation.

Implementations§

source§

impl Server<()>

source

pub fn new() -> Server<ThreadPool>

Constructs a new server.

source

pub fn with_executor<E: Executor>(executor: E) -> Server<E>

Constructs a new server with the given executor.

source§

impl<E> Server<E>

source

pub fn include_date_header(self, include: bool) -> Self

Whether if include the Date header.

source

pub fn max_body_size(self, max_body_size_bytes: Option<usize>) -> Self

The max size in bytes the body is allowed to have, if the body surpasses that size the request will be rejected.

source

pub fn include_conn_info(self, insert_conn_info: bool) -> Self

Include connection information to the request extensions.

source

pub fn include_server_info(self, include_server_info: bool) -> Self

Include the server config to the request extensions.

source

pub fn on_ready<F>(self, f: F) -> Self
where F: FnOnce(&SocketAddr) + Send + 'static,

Adds a callback that will be executed right after the server starts.

source

pub fn handle(&self) -> ServerHandle

Returns a handle to the server.

source§

impl<E> Server<E>
where E: Executor,

source

pub fn listen<H, A: ToSocketAddrs>(self, addr: A, handler: H) -> Result<()>
where H: RequestHandler + Send + Sync + 'static,

Starts listening on the given address and handle incoming request with the given request handler.

Auto Trait Implementations§

§

impl<E> Freeze for Server<E>
where E: Freeze,

§

impl<E = ThreadPool> !RefUnwindSafe for Server<E>

§

impl<E> Send for Server<E>
where E: Send,

§

impl<E = ThreadPool> !Sync for Server<E>

§

impl<E> Unpin for Server<E>
where E: Unpin,

§

impl<E = ThreadPool> !UnwindSafe for Server<E>

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.