[−][src]Struct http_service_hyper::Builder
A builder for a Server
.
Methods
impl<I: TryStream, Sp> Builder<I, Sp>
[src]
pub fn with_spawner<Sp2>(self, new_spawner: Sp2) -> Builder<I, Sp2>
[src]
Sets the Spawn
to deal with starting connection tasks.
ⓘImportant traits for Server<I, S, Sp>pub fn serve<S: HttpService>(self, service: S) -> Server<I, S, Sp> where
I: TryStream + Unpin,
I::Ok: AsyncRead + AsyncWrite + Send + Unpin + 'static,
I::Error: Into<Box<dyn Error + Send + Sync>>,
Sp: Clone + Send + 'static,
&'a Sp: Spawn,
[src]
ⓘImportant traits for Server<I, S, Sp>
I: TryStream + Unpin,
I::Ok: AsyncRead + AsyncWrite + Send + Unpin + 'static,
I::Error: Into<Box<dyn Error + Send + Sync>>,
Sp: Clone + Send + 'static,
&'a Sp: Spawn,
Consume this Builder
, creating a Server
.
Examples
use http_service::{Response, Body}; use http_service_hyper::Server; use romio::TcpListener; // Construct an executor to run our tasks on let mut pool = futures::executor::ThreadPool::new()?; // And an HttpService to handle each connection... let service = |req| { futures::future::ok::<_, ()>(Response::new(Body::from("Hello World"))) }; // Then bind, configure the spawner to our pool, and serve... let addr = "127.0.0.1:3000".parse()?; let mut listener = TcpListener::bind(&addr)?; let server = Server::builder(listener.incoming()) .with_spawner(pool.clone()) .serve(service); // Finally, spawn `server` onto our executor... pool.run(server)?;
Trait Implementations
Auto Trait Implementations
impl<I, Sp> Sync for Builder<I, Sp> where
I: Sync,
Sp: Sync,
I: Sync,
Sp: Sync,
impl<I, Sp> Unpin for Builder<I, Sp> where
I: Unpin,
Sp: Unpin,
I: Unpin,
Sp: Unpin,
impl<I, Sp> Send for Builder<I, Sp> where
I: Send,
Sp: Send,
I: Send,
Sp: Send,
impl<I, Sp> UnwindSafe for Builder<I, Sp> where
I: UnwindSafe,
Sp: UnwindSafe,
I: UnwindSafe,
Sp: UnwindSafe,
impl<I, Sp> RefUnwindSafe for Builder<I, Sp> where
I: RefUnwindSafe,
Sp: RefUnwindSafe,
I: RefUnwindSafe,
Sp: RefUnwindSafe,
Blanket Implementations
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> From<T> for T
[src]
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.
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.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,