Browse Source

Fix bug with author and impl ``From`` for ``MiiConfigIndex``

pull/78/head
TechiePi 2 years ago
parent
commit
b33411f8ac
  1. 12
      ctru-rs/src/applets/mii_selector.rs

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

@ -127,8 +127,10 @@ impl MiiSelectorReturn { @@ -127,8 +127,10 @@ impl MiiSelectorReturn {
pub fn author(&self) -> String {
let mut tmp = [0u8; 30];
unsafe { ctru_sys::miiSelectorReturnGetName(self.raw_return.as_ref(), tmp.as_mut_ptr(), 30) }
let utf8 = unsafe { std::str::from_utf8_unchecked(&tmp) };
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]) };
utf8.to_owned()
}
@ -163,4 +165,10 @@ impl From<Box<ctru_sys::MiiSelectorReturn>> for MiiSelectorReturn { @@ -163,4 +165,10 @@ impl From<Box<ctru_sys::MiiSelectorReturn>> for MiiSelectorReturn {
checksum,
}
}
}
impl From<u32> for MiiConfigIndex {
fn from(v: u32) -> Self {
Self::Index(v)
}
}
Loading…
Cancel
Save