Struct ctru::services::apt::Apt

source ·
pub struct Apt(/* private fields */);
Expand description

Handle to the Applet service.

Implementations§

source§

impl Apt

source

pub fn new() -> Result<Apt>

Initialize a new service handle.

§Example
use ctru::services::apt::Apt;

let apt = Apt::new()?;
source

pub fn main_loop(&self) -> bool

Returns true if the application is running in the foreground as normal.

§Notes

This function is called as such since it automatically handles all checks for Home Menu switching, Sleep mode and other events that could take away control from the application. For this reason, its main use is as the condition of a while loop that controls the main logic for your program.

§Example
use std::error::Error;
use ctru::services::apt::Apt;

// In a simple `main` function, the structure should be the following.
fn main() -> Result<(), Box<dyn Error>> {

let apt = Apt::new()?;

while apt.main_loop() {
    // Main program logic should be written here.
}

// Optional clean-ups after running the application should be written after the main loop.
source

pub fn set_app_cpu_time_limit(&mut self, percent: u32) -> Result<()>

Set (in percentage) the amount of time to lend to the application thread spawned on the syscore (core #1).

§Notes

It is necessary to set a time limit before spawning threads on the syscore. The percentage value must be withing 5% and 89%, though it is suggested to use lower values (around 30-45%) to avoid slowing down the OS processes.

source

pub fn set_sleep_allowed(&mut self, allowed: bool)

Set if the console is allowed to enter sleep mode.

You can check whether the console is allowed to sleep with Apt::is_sleep_allowed.

source

pub fn is_sleep_allowed(&self) -> bool

Check if the console is allowed to enter sleep mode.

You can set whether the console is allowed to sleep with Apt::set_sleep_allowed.

source

pub fn set_home_allowed(&mut self, allowed: bool)

Set if the console is allowed to enter the home menu.

You can check whether the console is allowed to enter the home menu with Apt::is_home_allowed.

source

pub fn is_home_allowed(&self) -> bool

Check if the console is allowed to enter the home menu.

You can set whether the console is allowed to enter the home menu with Apt::set_home_allowed.

source

pub fn jump_to_home_menu(&mut self)

Immediately jumps to the home menu.

Trait Implementations§

source§

impl Drop for Apt

source§

fn drop(&mut self)

Executes the destructor for this type. Read more

Auto Trait Implementations§

§

impl RefUnwindSafe for Apt

§

impl Send for Apt

§

impl Sync for Apt

§

impl Unpin for Apt

§

impl UnwindSafe for Apt

Blanket Implementations§

§

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

§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

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

§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
§

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

§

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

Mutably borrows from an owned value. Read more
§

impl<T> From<T> for T

§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T, U> Into<U> for T
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 T
where U: Into<T>,

§

type Error = Infallible

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

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

Performs the conversion.
§

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

§

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

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

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

Performs the conversion.