pub struct PTMUser { /* private fields */ }Expand description
Handle to the PTM:User service.
Implementations§
Source§impl PTMUser
impl PTMUser
Sourcepub fn shell_state(&self) -> Result<ShellState>
pub fn shell_state(&self) -> Result<ShellState>
Returns whether the console’s clamshell is closed or open.
§Example
use ctru::services::ptm::user::{PTMUser, ShellState};
let ptmu = PTMUser::new()?;
let state = ptmu.shell_state()?;
match state {
ShellState::Closed => println!("The shell is closed! How are you able to read this?"),
ShellState::Open => println!("The shell is open! That might seem obvious to you."),
}Sourcepub fn battery_level(&self) -> Result<BatteryLevel>
pub fn battery_level(&self) -> Result<BatteryLevel>
Returns the console’s current battery charge level.
§Example
use ctru::services::ptm::user::{PTMUser, BatteryLevel};
let ptmu = PTMUser::new()?;
let charge = ptmu.battery_level()?;
if charge <= BatteryLevel::Low {
println!("You should put the console to charge!");
}Sourcepub fn is_charging(&self) -> Result<bool>
pub fn is_charging(&self) -> Result<bool>
Returns whether the console is currently charging its battery.
§Example
use ctru::services::ptm::user::PTMUser;
let ptmu = PTMUser::new()?;
let is_charging = ptmu.is_charging()?;
if is_charging {
println!("That is one juicy power line.");
}Sourcepub fn step_count(&self) -> Result<u32>
pub fn step_count(&self) -> Result<u32>
Returns the console’s total step count.
§Example
use ctru::services::ptm::user::PTMUser;
let ptmu = PTMUser::new()?;
let steps = ptmu.step_count()?;
println!("You accumulated {steps} steps. Don't stop moving!");