hyper_sync::server

Struct Server

Source
pub struct Server<L = HttpListener> { /* private fields */ }
Expand description

A server can listen on a TCP socket.

Once listening, it will create a Request/Response pair for each incoming connection, and hand them to the provided handler.

Implementations§

Source§

impl<L: NetworkListener> Server<L>

Source

pub fn new(listener: L) -> Server<L>

Creates a new server with the provided handler.

Source

pub fn keep_alive(&mut self, timeout: Option<Duration>)

Controls keep-alive for this server.

The timeout duration passed will be used to determine how long to keep the connection alive before dropping it.

Passing None will disable keep-alive.

Default is enabled with a 5 second timeout.

Source

pub fn set_read_timeout(&mut self, dur: Option<Duration>)

Sets the read timeout for all Request reads.

Source

pub fn set_write_timeout(&mut self, dur: Option<Duration>)

Sets the write timeout for all Response writes.

Source

pub fn local_addr(&mut self) -> Result<SocketAddr>

Get the address that the server is listening on.

Source§

impl Server<HttpListener>

Source

pub fn http<To: ToSocketAddrs>(addr: To) -> Result<Server<HttpListener>>

Creates a new server that will handle HttpStreams.

Source§

impl<S: SslServer + Clone + Send> Server<HttpsListener<S>>

Source

pub fn https<A: ToSocketAddrs>( addr: A, ssl: S, ) -> Result<Server<HttpsListener<S>>>

Creates a new server that will handle HttpStreams over SSL.

You can use any SSL implementation, as long as implements hyper_sync::net::Ssl.

Source§

impl<L: NetworkListener + Send + 'static> Server<L>

Source

pub fn handle<H: Handler + 'static>(self, handler: H) -> Result<Listening>

Binds to a socket and starts handling connections.

Source

pub fn handle_threads<H: Handler + 'static>( self, handler: H, threads: usize, ) -> Result<Listening>

Binds to a socket and starts handling connections with the provided number of threads.

Trait Implementations§

Source§

impl<L: Debug> Debug for Server<L>

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

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

§

impl<L> RefUnwindSafe for Server<L>
where L: RefUnwindSafe,

§

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

§

impl<L> Sync for Server<L>
where L: Sync,

§

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

§

impl<L> UnwindSafe for Server<L>
where L: 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.