pub struct Server<S, M = Identity, L = SocketAddr, A = (), R = Runtime> { /* private fields */ }
Expand description
An HTTP server.
Implementations
sourceimpl<S> Server<S>where
S: NewService,
impl<S> Server<S>where
S: NewService,
sourceimpl<S, M, L, A, R> Server<S, M, L, A, R>
impl<S, M, L, A, R> Server<S, M, L, A, R>
sourcepub fn bind<L2>(self, listener: L2) -> Server<S, M, L2, A, R>where
L2: Listener,
pub fn bind<L2>(self, listener: L2) -> Server<S, M, L2, A, R>where
L2: Listener,
Sets the transport used by the server.
By default, a TCP transport with the listener address "127.0.0.1:4000"
is set.
sourcepub fn acceptor<A2>(self, acceptor: A2) -> Server<S, M, L, A2, R>where
L: Listener,
A2: Acceptor<L::Conn>,
pub fn acceptor<A2>(self, acceptor: A2) -> Server<S, M, L, A2, R>where
L: Listener,
A2: Acceptor<L::Conn>,
Sets the instance of Acceptor
to the server.
By default, the raw acceptor is set, which returns the incoming I/Os directly.
sourcepub fn protocol(self, protocol: Http) -> Self
pub fn protocol(self, protocol: Http) -> Self
Sets the HTTP-level configuration to this server.
Note that the executor will be overwritten by the launcher.
sourcepub fn modify_service<M2>(self, modify_service: M2) -> Server<S, M2, L, A, R>where
S: NewService,
M2: ModifyService<S::Service>,
pub fn modify_service<M2>(self, modify_service: M2) -> Server<S, M2, L, A, R>where
S: NewService,
M2: ModifyService<S::Service>,
Sets the middleware to this server.
pub fn tower_middleware<M2>(
self,
middleware: M2
) -> Server<S, Compat<M2>, L, A, R>where
S: NewService,
M2: Middleware<S::Service>,
sourcepub fn runtime<R2>(self, runtime: R2) -> Server<S, M, L, A, R2>
pub fn runtime<R2>(self, runtime: R2) -> Server<S, M, L, A, R2>
Sets the instance of runtime to the specified runtime
.
sourcepub fn current_thread(self) -> Server<S, M, L, A, Runtime>
pub fn current_thread(self) -> Server<S, M, L, A, Runtime>
Switches the runtime to be used to current_thread::Runtime
.
sourceimpl<S, M, T, A> Server<S, M, T, A, Runtime>where
S: MakeHttpService + Send + 'static,
S::Future: Send + 'static,
M: ModifyHttpService<S::Service> + Send + Sync + 'static,
M::Service: Send + 'static,
<M::Service as HttpService>::Future: Send + 'static,
T: Listener,
T::Incoming: Send + 'static,
A: Acceptor<T::Conn> + Send + 'static,
A::Conn: Send + 'static,
A::Error: Into<Box<dyn Error + Send + Sync + 'static>>,
<A::Conn as Connection>::Info: Send + 'static,
<A::Conn as Connection>::Error: Into<Box<dyn Error + Send + Sync + 'static>>,
A::Accept: Send + 'static,
impl<S, M, T, A> Server<S, M, T, A, Runtime>where
S: MakeHttpService + Send + 'static,
S::Future: Send + 'static,
M: ModifyHttpService<S::Service> + Send + Sync + 'static,
M::Service: Send + 'static,
<M::Service as HttpService>::Future: Send + 'static,
T: Listener,
T::Incoming: Send + 'static,
A: Acceptor<T::Conn> + Send + 'static,
A::Conn: Send + 'static,
A::Error: Into<Box<dyn Error + Send + Sync + 'static>>,
<A::Conn as Connection>::Info: Send + 'static,
<A::Conn as Connection>::Error: Into<Box<dyn Error + Send + Sync + 'static>>,
A::Accept: Send + 'static,
sourceimpl<S, M, T, A> Server<S, M, T, A, Runtime>where
S: MakeHttpService,
S::Future: 'static,
M: ModifyHttpService<S::Service> + 'static,
M::Service: 'static,
<M::Service as HttpService>::Future: 'static,
T: Listener,
T::Incoming: 'static,
A: Acceptor<T::Conn> + 'static,
A::Conn: Send + 'static,
A::Error: Into<Box<dyn Error + Send + Sync + 'static>>,
<A::Conn as Connection>::Info: 'static,
<A::Conn as Connection>::Error: Into<Box<dyn Error + Send + Sync + 'static>>,
A::Accept: 'static,
impl<S, M, T, A> Server<S, M, T, A, Runtime>where
S: MakeHttpService,
S::Future: 'static,
M: ModifyHttpService<S::Service> + 'static,
M::Service: 'static,
<M::Service as HttpService>::Future: 'static,
T: Listener,
T::Incoming: 'static,
A: Acceptor<T::Conn> + 'static,
A::Conn: Send + 'static,
A::Error: Into<Box<dyn Error + Send + Sync + 'static>>,
<A::Conn as Connection>::Info: 'static,
<A::Conn as Connection>::Error: Into<Box<dyn Error + Send + Sync + 'static>>,
A::Accept: 'static,
Trait Implementations
Auto Trait Implementations
impl<S, M = Identity, L = SocketAddr, A = (), R = Runtime> !RefUnwindSafe for Server<S, M, L, A, R>
impl<S, M, L, A, R> Send for Server<S, M, L, A, R>where
A: Send,
L: Send,
M: Send,
R: Send,
S: Send,
impl<S, M, L, A, R> Sync for Server<S, M, L, A, R>where
A: Sync,
L: Sync,
M: Sync,
R: Sync,
S: Sync,
impl<S, M, L, A, R> Unpin for Server<S, M, L, A, R>where
A: Unpin,
L: Unpin,
M: Unpin,
R: Unpin,
S: Unpin,
impl<S, M = Identity, L = SocketAddr, A = (), R = Runtime> !UnwindSafe for Server<S, M, L, A, R>
Blanket Implementations
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more