Browse Source

Cargo fmt

pull/78/head
TechiePi 2 years ago
parent
commit
de51d97d1c
  1. 2
      ctru-rs/examples/mii_selector.rs
  2. 89
      ctru-rs/src/applets/mii_selector.rs
  3. 2
      ctru-rs/src/applets/mod.rs

2
ctru-rs/examples/mii_selector.rs

@ -38,4 +38,4 @@ fn main() { @@ -38,4 +38,4 @@ fn main() {
//Wait for VBlank
gfx.wait_for_vblank();
}
}
}

89
ctru-rs/src/applets/mii_selector.rs

@ -1,5 +1,5 @@ @@ -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 { @@ -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 { @@ -39,7 +36,9 @@ pub struct MiiSelectorReturn {
impl MiiSelector {
pub fn init() -> Self {
let mut config = Box::<ctru_sys::MiiSelectorConf>::default();
unsafe { ctru_sys::miiSelectorInit(config.as_mut()); }
unsafe {
ctru_sys::miiSelectorInit(config.as_mut());
}
Self { config }
}
@ -47,7 +46,9 @@ impl MiiSelector { @@ -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 { @@ -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 { @@ -106,9 +119,7 @@ impl MiiSelector {
pub fn launch(&mut self) -> MiiSelectorReturn {
let mut return_val = Box::<ctru_sys::MiiSelectorReturn>::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 { @@ -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 { @@ -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<u32> for MiiConfigIndex { @@ -171,4 +186,4 @@ impl From<u32> for MiiConfigIndex {
fn from(v: u32) -> Self {
Self::Index(v)
}
}
}

2
ctru-rs/src/applets/mod.rs

@ -1,2 +1,2 @@ @@ -1,2 +1,2 @@
pub mod mii_selector;
pub mod swkbd;
pub mod mii_selector;
Loading…
Cancel
Save