pub enum ServerFuture {
Init {
server: Server,
enable_signal: bool,
},
Running(ServerFutureInner),
Error(Error),
Finished,
}
Variants§
Implementations§
Source§impl ServerFuture
impl ServerFuture
Sourcepub fn handle(&mut self) -> Result<ServerHandle>
pub fn handle(&mut self) -> Result<ServerHandle>
A handle for mutate Server state.
§Examples:
let mut server = Builder::new()
.bind("test", "127.0.0.1:0", fn_service(|_io: TcpStream| async { Ok::<_, ()>(())}))
.unwrap()
.build();
// obtain a handle. if server fail to start a std::io::Error would return.
let handle = server.handle().unwrap();
// spawn server future.
tokio::spawn(server);
// do a graceful shutdown of server.
handle.stop(true);
Sourcepub fn wait(self) -> Result<()>
pub fn wait(self) -> Result<()>
Consume ServerFuture and block current thread waitting for server stop.
Server can be stopped through OS signal or ServerHandle::stop. If none is active this call would block forever.
Trait Implementations§
Source§impl Default for ServerFuture
impl Default for ServerFuture
Source§impl Future for ServerFuture
impl Future for ServerFuture
Auto Trait Implementations§
impl !Freeze for ServerFuture
impl !RefUnwindSafe for ServerFuture
impl Send for ServerFuture
impl !Sync for ServerFuture
impl Unpin for ServerFuture
impl !UnwindSafe for ServerFuture
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<F> IntoFuture for Fwhere
F: Future,
impl<F> IntoFuture for Fwhere
F: Future,
Source§type IntoFuture = F
type IntoFuture = F
Which kind of future are we turning this into?
Source§fn into_future(self) -> <F as IntoFuture>::IntoFuture
fn into_future(self) -> <F as IntoFuture>::IntoFuture
Creates a future from a value. Read more