Struct Server

Source
pub struct Server { /* private fields */ }

Implementations§

Source§

impl Server

Source

pub fn new(addr: &str) -> Result<Self>

Initialize a new default Server to run on addr

Source

pub fn tcp_nodelay(&mut self, no_delay: bool) -> &mut Self

Configure tcp_nodelay setting for each server socket. Default: false

From mio::net::TcpStream docs:

Sets the value of the TCP_NODELAY option on this socket. If set, this option disables the Nagle algorithm. This means that segments are always sent as soon as possible, even if there is only a small amount of data. When not set, data is buffered until there is a sufficient amount to send out, thereby avoiding the frequent sending of small packets.

Note: tcp_nodelay(true) will significantly improve performance for benchmarking loads, but may not be necessary for real world usage. For example on my laptop, wrk -t2 -c100 increases from 2.5k to 92k req/s.

Source

pub fn pool_size(&mut self, pool_size: usize) -> &mut Self

Configure the size of the thread pool that’s used for executing handlers

Defaults to num_cpus * 8. If zero is specified, unlimited threads will be spawned instead of using a thread pool.

Source

pub fn set_keepalive_secs(&mut self, keep_alive_secs: u64) -> &mut Self

Configure keep-alive timeout in seconds

Defaults to 5 seconds

Source

pub fn start<F>(&self, func: F) -> Result<()>
where F: Send + Sync + 'static + Fn(Request) -> Response<Vec<u8>>,

Start the server using the given handler function

Auto Trait Implementations§

§

impl Freeze for Server

§

impl RefUnwindSafe for Server

§

impl Send for Server

§

impl Sync for Server

§

impl Unpin for Server

§

impl UnwindSafe for Server

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.