Struct hyper_static_server::hyper::server::Builder [−][src]
A builder for a Server
.
Implementations
impl<I, E> Builder<I, E>
[src]
pub fn new(incoming: I, protocol: Http<E>) -> Builder<I, E>
[src]
Start 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) -> Builder<I, E>
[src]
Sets whether to use keep-alive for HTTP/1 connections.
Default is true
.
pub fn http1_half_close(self, val: bool) -> Builder<I, E>
[src]
Set whether HTTP/1 connections should support half-closures.
Clients can chose to shutdown their write-side while waiting
for the server to respond. Setting this to true
will
prevent closing the connection immediately if read
detects an EOF in the middle of a request.
Default is false
.
pub fn http1_max_buf_size(self, val: usize) -> Builder<I, E>
[src]
Set the maximum buffer size.
Default is ~ 400kb.
pub fn http1_only(self, val: bool) -> Builder<I, E>
[src]
Sets whether HTTP/1 is required.
Default is false
.
pub fn http2_only(self, val: bool) -> Builder<I, E>
[src]
Sets whether HTTP/2 is required.
Default is false
.
pub fn http2_initial_stream_window_size(
self,
sz: impl Into<Option<u32>>
) -> Builder<I, E>
[src]
self,
sz: impl Into<Option<u32>>
) -> Builder<I, E>
Sets the SETTINGS_INITIAL_WINDOW_SIZE
option for HTTP2
stream-level flow control.
Passing None
will do nothing.
If not set, hyper will use a default.
pub fn http2_initial_connection_window_size(
self,
sz: impl Into<Option<u32>>
) -> Builder<I, E>
[src]
self,
sz: impl Into<Option<u32>>
) -> Builder<I, E>
Sets the max connection-level flow control for HTTP2
Passing None
will do nothing.
If not set, hyper will use a default.
pub fn http2_adaptive_window(self, enabled: bool) -> Builder<I, E>
[src]
Sets whether to use an adaptive flow control.
Enabling this will override the limits set in
http2_initial_stream_window_size
and
http2_initial_connection_window_size
.
pub fn http2_max_frame_size(self, sz: impl Into<Option<u32>>) -> Builder<I, E>
[src]
Sets the maximum frame size to use for HTTP2.
Passing None
will do nothing.
If not set, hyper will use a default.
pub fn http2_max_concurrent_streams(
self,
max: impl Into<Option<u32>>
) -> Builder<I, E>
[src]
self,
max: impl Into<Option<u32>>
) -> Builder<I, E>
Sets the SETTINGS_MAX_CONCURRENT_STREAMS
option for HTTP2
connections.
Default is no limit (std::u32::MAX
). Passing None
will do nothing.
pub fn executor<E2>(self, executor: E2) -> Builder<I, E2>
[src]
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>ⓘNotable traits for Server<I, S, E>
impl<I, IO, IE, S, B, E> Future for Server<I, S, E> where
B: Body + 'static,
E: ConnStreamExec<<<S as MakeServiceRef<IO, Body>>::Service as HttpService<Body>>::Future, B> + NewSvcExec<IO, <S as MakeServiceRef<IO, Body>>::Future, <S as MakeServiceRef<IO, Body>>::Service, E, NoopWatcher>,
S: MakeServiceRef<IO, Body, ResBody = B>,
I: Accept<Conn = IO, Error = IE>,
IO: AsyncRead + AsyncWrite + Unpin + Send + 'static,
IE: Into<Box<dyn Error + 'static + Sync + Send, Global>>,
<S as MakeServiceRef<IO, Body>>::Error: Into<Box<dyn Error + 'static + Sync + Send, Global>>,
<B as Body>::Error: Into<Box<dyn Error + 'static + Sync + Send, Global>>, type Output = Result<(), Error>;
where
B: Body + 'static,
E: NewSvcExec<<I as Accept>::Conn, <S as MakeServiceRef<<I as Accept>::Conn, Body>>::Future, <S as MakeServiceRef<<I as Accept>::Conn, Body>>::Service, E, NoopWatcher> + ConnStreamExec<<<S as MakeServiceRef<<I as Accept>::Conn, Body>>::Service as HttpService<Body>>::Future, B>,
S: MakeServiceRef<<I as Accept>::Conn, Body, ResBody = B>,
I: Accept,
<I as Accept>::Error: Into<Box<dyn Error + 'static + Sync + Send, Global>>,
<I as Accept>::Conn: AsyncRead,
<I as Accept>::Conn: AsyncWrite,
<I as Accept>::Conn: Unpin,
<I as Accept>::Conn: Send,
<I as Accept>::Conn: 'static,
<S as MakeServiceRef<<I as Accept>::Conn, Body>>::Error: Into<Box<dyn Error + 'static + Sync + Send, Global>>,
<B as Body>::Error: Into<Box<dyn Error + 'static + Sync + Send, Global>>,
[src]
Notable traits for Server<I, S, E>
impl<I, IO, IE, S, B, E> Future for Server<I, S, E> where
B: Body + 'static,
E: ConnStreamExec<<<S as MakeServiceRef<IO, Body>>::Service as HttpService<Body>>::Future, B> + NewSvcExec<IO, <S as MakeServiceRef<IO, Body>>::Future, <S as MakeServiceRef<IO, Body>>::Service, E, NoopWatcher>,
S: MakeServiceRef<IO, Body, ResBody = B>,
I: Accept<Conn = IO, Error = IE>,
IO: AsyncRead + AsyncWrite + Unpin + Send + 'static,
IE: Into<Box<dyn Error + 'static + Sync + Send, Global>>,
<S as MakeServiceRef<IO, Body>>::Error: Into<Box<dyn Error + 'static + Sync + Send, Global>>,
<B as Body>::Error: Into<Box<dyn Error + 'static + Sync + Send, Global>>, type Output = Result<(), Error>;
B: Body + 'static,
E: NewSvcExec<<I as Accept>::Conn, <S as MakeServiceRef<<I as Accept>::Conn, Body>>::Future, <S as MakeServiceRef<<I as Accept>::Conn, Body>>::Service, E, NoopWatcher> + ConnStreamExec<<<S as MakeServiceRef<<I as Accept>::Conn, Body>>::Service as HttpService<Body>>::Future, B>,
S: MakeServiceRef<<I as Accept>::Conn, Body, ResBody = B>,
I: Accept,
<I as Accept>::Error: Into<Box<dyn Error + 'static + Sync + Send, Global>>,
<I as Accept>::Conn: AsyncRead,
<I as Accept>::Conn: AsyncWrite,
<I as Accept>::Conn: Unpin,
<I as Accept>::Conn: Send,
<I as Accept>::Conn: 'static,
<S as MakeServiceRef<<I as Accept>::Conn, Body>>::Error: Into<Box<dyn Error + 'static + Sync + Send, Global>>,
<B as Body>::Error: Into<Box<dyn Error + 'static + Sync + Send, Global>>,
Consume this Builder
, creating a Server
.
Example
use hyper::{Body, Error, Response, Server}; use hyper::service::{make_service_fn, service_fn}; // Construct our SocketAddr to listen on... let addr = ([127, 0, 0, 1], 3000).into(); // And a MakeService to handle each connection... let make_svc = make_service_fn(|_| async { Ok::<_, Error>(service_fn(|_req| async { Ok::<_, Error>(Response::new(Body::from("Hello World"))) })) }); // Then bind and serve... let server = Server::bind(&addr) .serve(make_svc); // Run forever-ish... if let Err(err) = server.await { eprintln!("server error: {}", err); }
Trait Implementations
Auto Trait Implementations
impl<I, E> RefUnwindSafe for Builder<I, E> where
E: RefUnwindSafe,
I: RefUnwindSafe,
E: RefUnwindSafe,
I: RefUnwindSafe,
impl<I, E> Send for Builder<I, E> where
E: Send,
I: Send,
E: Send,
I: Send,
impl<I, E> Sync for Builder<I, E> where
E: Sync,
I: Sync,
E: Sync,
I: Sync,
impl<I, E> Unpin for Builder<I, E> where
E: Unpin,
I: Unpin,
E: Unpin,
I: Unpin,
impl<I, E> UnwindSafe for Builder<I, E> where
E: UnwindSafe,
I: UnwindSafe,
E: UnwindSafe,
I: UnwindSafe,
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut Tⓘ
[src]
impl<EI, EO> ErrorExtWrap<EO> for EI where
EO: ErrorExtWrapFrom<EI>,
[src]
EO: ErrorExtWrapFrom<EI>,
impl<T> From<T> for T
[src]
impl<T> Instrument for T
[src]
pub fn instrument(self, span: Span) -> Instrumented<Self>ⓘNotable traits for Instrumented<T>
impl<T> Future for Instrumented<T> where
T: Future, type Output = <T as Future>::Output;
[src]
Notable traits for Instrumented<T>
impl<T> Future for Instrumented<T> where
T: Future, type Output = <T as Future>::Output;
pub fn in_current_span(self) -> Instrumented<Self>ⓘNotable traits for Instrumented<T>
impl<T> Future for Instrumented<T> where
T: Future, type Output = <T as Future>::Output;
[src]
Notable traits for Instrumented<T>
impl<T> Future for Instrumented<T> where
T: Future, type Output = <T as Future>::Output;
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> Same<T> for T
type Output = T
Should always be Self
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
pub fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,