[−][src]Struct hyper::server::Builder
A builder for a Server.
Methods
impl<I, E> Builder<I, E>[src]
impl<I, E> Builder<I, E>pub fn new(incoming: I, protocol: Http_<E>) -> Self[src]
pub fn new(incoming: I, protocol: Http_<E>) -> SelfStart a new builder, wrapping an incoming stream and low-level options.
For a more convenient constructor, see Server::bind.
pub fn http1_keepalive(self, val: bool) -> Self[src]
pub fn http1_keepalive(self, val: bool) -> SelfSets whether to use keep-alive for HTTP/1 connections.
Default is true.
pub fn http1_only(self, val: bool) -> Self[src]
pub fn http1_only(self, val: bool) -> SelfSets whether HTTP/1 is required.
Default is false.
pub fn http1_writev(self, val: bool) -> Self[src]
pub fn http1_writev(self, val: bool) -> SelfSet whether HTTP/1 connections should try to use vectored writes, or always flatten into a single buffer.
Note
Setting this to false may mean more copies of body data,
but may also improve performance when an IO transport doesn't
support vectored writes well, such as most TLS implementations.
Default is true.
pub fn http2_only(self, val: bool) -> Self[src]
pub fn http2_only(self, val: bool) -> SelfSets whether HTTP/2 is required.
Default is false.
pub fn executor<E2>(self, executor: E2) -> Builder<I, E2>[src]
pub fn executor<E2>(self, executor: E2) -> Builder<I, E2>Sets the Executor to deal with connection tasks.
Default is tokio::spawn.
pub fn serve<S, B>(self, new_service: S) -> Server<I, S, E> where
I: Stream,
I::Error: Into<Box<Error + Send + Sync>>,
I::Item: AsyncRead + AsyncWrite + Send + 'static,
S: MakeServiceRef<I::Item, ReqBody = Body, ResBody = B>,
S::Error: Into<Box<Error + Send + Sync>>,
S::Service: 'static,
B: Payload,
E: NewSvcExec<I::Item, S::Future, S::Service, E, NoopWatcher>,
E: H2Exec<<S::Service as Service>::Future, B>, [src]
pub fn serve<S, B>(self, new_service: S) -> Server<I, S, E> where
I: Stream,
I::Error: Into<Box<Error + Send + Sync>>,
I::Item: AsyncRead + AsyncWrite + Send + 'static,
S: MakeServiceRef<I::Item, ReqBody = Body, ResBody = B>,
S::Error: Into<Box<Error + Send + Sync>>,
S::Service: 'static,
B: Payload,
E: NewSvcExec<I::Item, S::Future, S::Service, E, NoopWatcher>,
E: H2Exec<<S::Service as Service>::Future, B>, Consume this Builder, creating a Server.
Example
use hyper::{Body, Response, Server}; use hyper::service::service_fn_ok; // Construct our SocketAddr to listen on... let addr = ([127, 0, 0, 1], 3000).into(); // And a NewService to handle each connection... let new_service = || { service_fn_ok(|_req| { Response::new(Body::from("Hello World")) }) }; // Then bind and serve... let server = Server::bind(&addr) .serve(new_service); // Finally, spawn `server` onto an Executor...
impl<E> Builder<AddrIncoming, E>[src]
impl<E> Builder<AddrIncoming, E>pub fn tcp_keepalive(self, keepalive: Option<Duration>) -> Self[src]
pub fn tcp_keepalive(self, keepalive: Option<Duration>) -> SelfSet whether TCP keepalive messages are enabled on accepted connections.
If None is specified, keepalive is disabled, otherwise the duration
specified will be the time to remain idle before sending TCP keepalive
probes.
pub fn tcp_nodelay(self, enabled: bool) -> Self[src]
pub fn tcp_nodelay(self, enabled: bool) -> SelfSet the value of TCP_NODELAY option for accepted connections.
Trait Implementations
Auto Trait Implementations
impl<I, E> Send for Builder<I, E> where
E: Send,
I: Send,
impl<I, E> Send for Builder<I, E> where
E: Send,
I: Send, impl<I, E> Sync for Builder<I, E> where
E: Sync,
I: Sync,
impl<I, E> Sync for Builder<I, E> where
E: Sync,
I: Sync, Blanket Implementations
impl<T> From for T[src]
impl<T> From for Timpl<T, U> Into for T where
U: From<T>, [src]
impl<T, U> Into for T where
U: From<T>, impl<T, U> TryFrom for T where
T: From<U>, [src]
impl<T, U> TryFrom for T where
T: From<U>, type Error = !
try_from)The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>[src]
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>try_from)Performs the conversion.
impl<T> Borrow for T where
T: ?Sized, [src]
impl<T> Borrow for T where
T: ?Sized, ⓘImportant traits for &'a mut Rfn borrow(&self) -> &T[src]
fn borrow(&self) -> &TImmutably borrows from an owned value. Read more
impl<T, U> TryInto for T where
U: TryFrom<T>, [src]
impl<T, U> TryInto for T where
U: TryFrom<T>, type Error = <U as TryFrom<T>>::Error
try_from)The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>[src]
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>try_from)Performs the conversion.
impl<T> BorrowMut for T where
T: ?Sized, [src]
impl<T> BorrowMut for T where
T: ?Sized, ⓘImportant traits for &'a mut Rfn borrow_mut(&mut self) -> &mut T[src]
fn borrow_mut(&mut self) -> &mut TMutably borrows from an owned value. Read more
impl<T> Any for T where
T: 'static + ?Sized, [src]
impl<T> Any for T where
T: 'static + ?Sized, fn get_type_id(&self) -> TypeId[src]
fn get_type_id(&self) -> TypeId🔬 This is a nightly-only experimental API. (get_type_id)
this method will likely be replaced by an associated static
Gets the TypeId of self. Read more
impl<T> Erased for T[src]
impl<T> Erased for T