[][src]Crate system_shutdown

system_shutdown provides a cross platform way to shut down, reboot or log out operations.

Supported platforms: Linux, Windows and MacOS.

Example

The example below shows how to shut down the machine:

extern crate system_shutdown;

use system_shutdown::shutdown;

fn main() {
    match shutdown() {
        Ok(_) => println!("Shutting down, bye!"),
        Err(error) => eprintln!("Failed to shut down: {}", error),
    }
}

In most of the systems it does not requires the user to be root/admin.

Functions

force_logout

Calls the OS-specific function to force to log out the user.

force_reboot

Calls the OS-specific function to force to reboot the machine.

force_shutdown

Calls the OS-specific function to force to shut down the machine.

logout

Calls the OS-specific function to log out the user.

reboot

Calls the OS-specific function to reboot the machine.

shutdown

Calls the OS-specific function to shut down the machine.

Type Definitions

ShutdownResult

A specialized Result type for shut down, reboot and log out operations.