From de51d97d1ca5427dc978b05bd8336ca3ee686984 Mon Sep 17 00:00:00 2001 From: TechiePi Date: Thu, 20 Oct 2022 23:13:27 +0200 Subject: [PATCH] Cargo fmt --- ctru-rs/examples/mii_selector.rs | 2 +- ctru-rs/src/applets/mii_selector.rs | 89 +++++++++++++++++------------ ctru-rs/src/applets/mod.rs | 2 +- 3 files changed, 54 insertions(+), 39 deletions(-) diff --git a/ctru-rs/examples/mii_selector.rs b/ctru-rs/examples/mii_selector.rs index a9d8779..40c774e 100644 --- a/ctru-rs/examples/mii_selector.rs +++ b/ctru-rs/examples/mii_selector.rs @@ -38,4 +38,4 @@ fn main() { //Wait for VBlank gfx.wait_for_vblank(); } -} \ No newline at end of file +} diff --git a/ctru-rs/src/applets/mii_selector.rs b/ctru-rs/src/applets/mii_selector.rs index 599a480..634cd88 100644 --- a/ctru-rs/src/applets/mii_selector.rs +++ b/ctru-rs/src/applets/mii_selector.rs @@ -1,5 +1,5 @@ -use std::ffi::{CString}; use bitflags::bitflags; +use std::ffi::CString; #[derive(Debug, Clone)] pub enum MiiConfigIndex { @@ -9,10 +9,7 @@ pub enum MiiConfigIndex { #[derive(Debug, Clone)] pub enum MiiType { - Guest { - index: u32, - name: String, - }, + Guest { index: u32, name: String }, User, } @@ -39,7 +36,9 @@ pub struct MiiSelectorReturn { impl MiiSelector { pub fn init() -> Self { let mut config = Box::::default(); - unsafe { ctru_sys::miiSelectorInit(config.as_mut()); } + unsafe { + ctru_sys::miiSelectorInit(config.as_mut()); + } Self { config } } @@ -47,7 +46,9 @@ impl MiiSelector { // This can only fail if the text contains NUL bytes in the string... which seems // unlikely and is documented let c_text = CString::new(text).expect("Cstring::new failed"); - unsafe { ctru_sys::miiSelectorSetTitle(self.config.as_mut(), c_text.as_ptr()); } + unsafe { + ctru_sys::miiSelectorSetTitle(self.config.as_mut(), c_text.as_ptr()); + } } pub fn set_options(&mut self, options: Options) { @@ -56,45 +57,57 @@ impl MiiSelector { pub fn whitelist_guest_mii(&mut self, mii_index: MiiConfigIndex) { match mii_index { - MiiConfigIndex::Index(i) => { - unsafe { ctru_sys::miiSelectorWhitelistGuestMii(self.config.as_mut(), i) } - } - MiiConfigIndex::All => { - unsafe { ctru_sys::miiSelectorWhitelistGuestMii(self.config.as_mut(), ctru_sys::MIISELECTOR_GUESTMII_SLOTS) } - } + MiiConfigIndex::Index(i) => unsafe { + ctru_sys::miiSelectorWhitelistGuestMii(self.config.as_mut(), i) + }, + MiiConfigIndex::All => unsafe { + ctru_sys::miiSelectorWhitelistGuestMii( + self.config.as_mut(), + ctru_sys::MIISELECTOR_GUESTMII_SLOTS, + ) + }, } } pub fn blacklist_guest_mii(&mut self, mii_index: MiiConfigIndex) { match mii_index { - MiiConfigIndex::Index(i) => { - unsafe { ctru_sys::miiSelectorBlacklistGuestMii(self.config.as_mut(), i) } - } - MiiConfigIndex::All => { - unsafe { ctru_sys::miiSelectorBlacklistGuestMii(self.config.as_mut(), ctru_sys::MIISELECTOR_GUESTMII_SLOTS) } - } + MiiConfigIndex::Index(i) => unsafe { + ctru_sys::miiSelectorBlacklistGuestMii(self.config.as_mut(), i) + }, + MiiConfigIndex::All => unsafe { + ctru_sys::miiSelectorBlacklistGuestMii( + self.config.as_mut(), + ctru_sys::MIISELECTOR_GUESTMII_SLOTS, + ) + }, } } pub fn whitelist_user_mii(&mut self, mii_index: MiiConfigIndex) { match mii_index { - MiiConfigIndex::Index(i) => { - unsafe { ctru_sys::miiSelectorWhitelistUserMii(self.config.as_mut(), i) } - } - MiiConfigIndex::All => { - unsafe { ctru_sys::miiSelectorWhitelistUserMii(self.config.as_mut(), ctru_sys::MIISELECTOR_USERMII_SLOTS) } - } + MiiConfigIndex::Index(i) => unsafe { + ctru_sys::miiSelectorWhitelistUserMii(self.config.as_mut(), i) + }, + MiiConfigIndex::All => unsafe { + ctru_sys::miiSelectorWhitelistUserMii( + self.config.as_mut(), + ctru_sys::MIISELECTOR_USERMII_SLOTS, + ) + }, } } pub fn blacklist_user_mii(&mut self, mii_index: MiiConfigIndex) { match mii_index { - MiiConfigIndex::Index(i) => { - unsafe { ctru_sys::miiSelectorBlacklistUserMii(self.config.as_mut(), i) } - } - MiiConfigIndex::All => { - unsafe { ctru_sys::miiSelectorBlacklistUserMii(self.config.as_mut(), ctru_sys::MIISELECTOR_USERMII_SLOTS) } - } + MiiConfigIndex::Index(i) => unsafe { + ctru_sys::miiSelectorBlacklistUserMii(self.config.as_mut(), i) + }, + MiiConfigIndex::All => unsafe { + ctru_sys::miiSelectorBlacklistUserMii( + self.config.as_mut(), + ctru_sys::MIISELECTOR_USERMII_SLOTS, + ) + }, } } @@ -106,9 +119,7 @@ impl MiiSelector { pub fn launch(&mut self) -> MiiSelectorReturn { let mut return_val = Box::::default(); - unsafe { - ctru_sys::miiSelectorLaunch(self.config.as_mut(), return_val.as_mut()) - } + unsafe { ctru_sys::miiSelectorLaunch(self.config.as_mut(), return_val.as_mut()) } return_val.into() } @@ -117,7 +128,9 @@ impl MiiSelector { impl MiiSelectorReturn { pub fn name(&self) -> String { let mut tmp = [0u8; 36]; - unsafe { ctru_sys::miiSelectorReturnGetName(self.raw_return.as_ref(), tmp.as_mut_ptr(), 36) } + unsafe { + ctru_sys::miiSelectorReturnGetName(self.raw_return.as_ref(), tmp.as_mut_ptr(), 36) + } let len = unsafe { libc::strlen(tmp.as_ptr()) }; let utf8 = unsafe { std::str::from_utf8_unchecked(&tmp[..len]) }; @@ -127,7 +140,9 @@ impl MiiSelectorReturn { pub fn author(&self) -> String { let mut tmp = [0u8; 30]; - unsafe { ctru_sys::miiSelectorReturnGetAuthor(self.raw_return.as_ref(), tmp.as_mut_ptr(), 30) } + unsafe { + ctru_sys::miiSelectorReturnGetAuthor(self.raw_return.as_ref(), tmp.as_mut_ptr(), 30) + } let len = unsafe { libc::strlen(tmp.as_ptr()) }; let utf8 = unsafe { std::str::from_utf8_unchecked(&tmp[..len]) }; @@ -171,4 +186,4 @@ impl From for MiiConfigIndex { fn from(v: u32) -> Self { Self::Index(v) } -} \ No newline at end of file +} diff --git a/ctru-rs/src/applets/mod.rs b/ctru-rs/src/applets/mod.rs index 47eec73..f5813ad 100644 --- a/ctru-rs/src/applets/mod.rs +++ b/ctru-rs/src/applets/mod.rs @@ -1,2 +1,2 @@ +pub mod mii_selector; pub mod swkbd; -pub mod mii_selector; \ No newline at end of file