[−][src]Struct simple_on_shutdown::ShutdownCallbackWambo
Simple type that holds a closure (callback). The closure gets invoked during drop()
.
This works also fine with applications that do gracefully shutdown via signals, like SIGTERM.
Create this type via on_shutdown!(println!("foobar"))
or on_shutdown!({e1; e2; e3; println!("foobar")})
.
See on_shutdown
for more info.
This crate uses the log
crate on the debug
level.
IMPORTANT: Use this on the top level of your main() or whatever your current runtimes main function is! The code gets executed when the context it lives in gets dropped. This can be called multiple times (at least with stable Rust 1.48.0) without problem.
Example:
use simple_on_shutdown::on_shutdown; fn main() { // some code ... // Important that the returned value of the macro lives through // the whole lifetime of main(). It gets dropped in the end. on_shutdown!(println!("shut down with success")); // can be used multiple times on_shutdown!(println!("shut down with success")); on_shutdown!({println!("blocks also work")}); // some code ... }
Name
Wambo ftw :D Reference: http://de.spongepedia.org/index.php/Wambo I didn't found a better name
Implementations
impl ShutdownCallbackWambo
[src]
pub fn new(inner: Box<dyn FnMut()>) -> Self
[src]
Constructor. Better use macro on_shutdown
.
Trait Implementations
impl Drop for ShutdownCallbackWambo
[src]
Auto Trait Implementations
impl !RefUnwindSafe for ShutdownCallbackWambo
impl !Send for ShutdownCallbackWambo
impl !Sync for ShutdownCallbackWambo
impl Unpin for ShutdownCallbackWambo
impl !UnwindSafe for ShutdownCallbackWambo
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<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
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>,