Skip to main content

Autosleep

Struct Autosleep 

pub struct Autosleep {
    path: PathBuf,
}
Expand description

Control of the kernel’s autosleep feature.

With autosleep enabled, the kernel suspends to memory whenever no wake lock is held.

The autosleep file has mode 0644 and belongs to root. Any user can read it, but only root can write it. A write waits for the kernel to abort a running suspend attempt. That includes a file system sync.

Fields§

§path: PathBuf

Implementations§

§

impl Autosleep

pub const DEFAULT_PATH: &'static str = "/sys/power/autosleep"

Default path of the autosleep file.

pub fn new() -> Self

Creates a handle for Self::DEFAULT_PATH.

pub fn with_path<P: Into<PathBuf>>(path: P) -> Self

Creates a handle for a custom autosleep file.

pub fn enable(&self) -> Result<(), Error>

Enables autosleep by writing mem.

§Errors

Returns an error if the autosleep file can’t be written.

pub fn disable(&self) -> Result<(), Error>

Disables autosleep by writing off.

§Errors

Returns an error if the autosleep file can’t be written.

pub fn set_enabled(&self, enabled: bool) -> Result<(), Error>

Enables or disables autosleep.

§Errors

Returns an error if the autosleep file can’t be written.

pub fn is_enabled(&self) -> Result<bool, Error>

Returns whether autosleep is enabled.

§Errors

Returns an error if the autosleep file can’t be read.

fn write(&self, value: &[u8]) -> Result<(), Error>

fn error(&self, source: Error) -> Error

Trait Implementations§

§

impl Clone for Autosleep

§

fn clone(&self) -> Autosleep

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
§

impl Debug for Autosleep

§

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

Formats the value using the given formatter. Read more
§

impl Default for Autosleep

§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

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

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

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

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

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

Source§

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

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

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

Source§

fn into(self) -> U

Calls U::from(self).

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

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

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

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

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

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

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

Performs the conversion.