Struct GracefulShutdown

pub struct GracefulShutdown { /* private fields */ }

A graceful shutdown utility

Implementations

impl GracefulShutdown

fn new() -> Self

Create a new graceful shutdown helper.

fn watch<C: GracefulConnection>(&self, conn: C) -> impl Future<Output = C::Output> + use<C>

Wrap a future for graceful shutdown watching.

fn watcher(&self) -> Watcher

Create an owned type that can watch a connection.

This method allows created an owned type that can be sent onto another task before calling [Watcher::watch()].

async fn shutdown(self)

Signal shutdown for all watched connections.

This returns a Future which will complete once all watched connections have shutdown.

fn count(&self) -> usize

Returns the number of the watching connections.

Trait Implementations

impl Debug for GracefulShutdown

fn fmt(&self, f: &mut Formatter<'_>) -> Result

impl Default for GracefulShutdown

fn default() -> Self

Auto Trait Implementations

impl !RefUnwindSafe for GracefulShutdown

impl !UnwindSafe for GracefulShutdown

impl Freeze for GracefulShutdown

impl Send for GracefulShutdown

impl Sync for GracefulShutdown

impl Unpin for GracefulShutdown

impl UnsafeUnpin for GracefulShutdown

Blanket Implementations

impl<T> Any for GracefulShutdown where T: 'static + ?Sized,

fn type_id(&self) -> TypeId

impl<T> Borrow<T> for GracefulShutdown where T: ?Sized,

fn borrow(&self) -> &T

impl<T> BorrowMut<T> for GracefulShutdown where T: ?Sized,

fn borrow_mut(&mut self) -> &mut T

impl<T> From<T> for GracefulShutdown

fn from(t: T) -> T

Returns the argument unchanged.

impl<T> Instrument for GracefulShutdown

impl<T> WithSubscriber for GracefulShutdown

impl<T, U> Into<U> for GracefulShutdown where U: From<T>,

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of [From]<T> for U chooses to do.

impl<T, U> TryFrom<U> for GracefulShutdown where U: Into<T>,

type Error = never;
fn try_from(value: U) -> Result<T, never>

impl<T, U> TryInto<U> for GracefulShutdown where U: TryFrom<T>,

type Error = <U as TryFrom<T>>::Error;
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>