Ferrum

Struct Ferrum 

Source
pub struct Ferrum<H>
where H: Handler,
{ pub handler: H, pub keep_alive: bool, pub timeout: Option<Duration>, pub num_threads: usize, }
Expand description

Server The primary entrance point to Ferrum, a struct to instantiate a new server.

Ferrum contains the Handler which takes a Request and produces a Response.

Fields§

§handler: H

Ferrum contains a Handler, which it uses to create responses for client requests.

§keep_alive: bool

Controls the timeout for keep alive connections.

The default is true.

§timeout: Option<Duration>

Server timeout.

§num_threads: usize

The number of request handling threads.

Defaults to num_cpus.

Implementations§

Source§

impl<H> Ferrum<H>
where H: Handler,

Source

pub fn new(handler: H) -> Ferrum<H>

Instantiate a new instance of Ferrum.

This will create a new Ferrum, the base unit of the server, using the passed in Handler.

Source

pub fn http<A>(self, addr: A) -> HyperResult<()>
where A: ToSocketAddrs,

Kick off the server process using the HTTP protocol.

Call this once to begin listening for requests on the server. This consumes the Ferrum instance. This method will block the current thread executing the HTTP server.

Source

pub fn server<A>(self, addr: A) -> HyperResult<Server<H>>
where A: ToSocketAddrs,

Bind the provided addr and return a server ready to handle connections.

Auto Trait Implementations§

§

impl<H> Freeze for Ferrum<H>
where H: Freeze,

§

impl<H> RefUnwindSafe for Ferrum<H>
where H: RefUnwindSafe,

§

impl<H> Send for Ferrum<H>

§

impl<H> Sync for Ferrum<H>

§

impl<H> Unpin for Ferrum<H>
where H: Unpin,

§

impl<H> UnwindSafe for Ferrum<H>
where H: UnwindSafe,

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.
Source§

impl<T> UnsafeAny for T
where T: Any,