-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'feature/ps-module' of https://github.com/ian-h-chamberl…
- Loading branch information
Showing
2 changed files
with
30 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,7 @@ pub mod apt; | |
pub mod fs; | ||
pub mod gspgpu; | ||
pub mod hid; | ||
pub mod ps; | ||
pub mod soc; | ||
pub mod sslc; | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
//! Process Services (PS) module. This is used for miscellaneous utility tasks, but | ||
//! is particularly important because it is used to generate random data, which | ||
//! is required for common things like [`HashMap`](std::collections::HashMap). | ||
//! See also <https://www.3dbrew.org/wiki/Process_Services> | ||
/// PS handle. This must not be dropped in order for random generation | ||
/// to work (in most cases, the lifetime of an application). | ||
#[non_exhaustive] | ||
pub struct Ps; | ||
|
||
impl Ps { | ||
/// Initialize the PS module. | ||
pub fn init() -> crate::Result<Self> { | ||
let r = unsafe { ctru_sys::psInit() }; | ||
if r < 0 { | ||
Err(r.into()) | ||
} else { | ||
Ok(Self) | ||
} | ||
} | ||
} | ||
|
||
impl Drop for Ps { | ||
fn drop(&mut self) { | ||
unsafe { | ||
ctru_sys::psExit(); | ||
} | ||
} | ||
} |