From b33411f8ac52ef19770e61fb410ac1f11c330ab1 Mon Sep 17 00:00:00 2001 From: TechiePi Date: Thu, 20 Oct 2022 22:16:58 +0200 Subject: [PATCH] Fix bug with author and impl ``From`` for ``MiiConfigIndex`` --- ctru-rs/src/applets/mii_selector.rs | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/ctru-rs/src/applets/mii_selector.rs b/ctru-rs/src/applets/mii_selector.rs index a54729a..599a480 100644 --- a/ctru-rs/src/applets/mii_selector.rs +++ b/ctru-rs/src/applets/mii_selector.rs @@ -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> for MiiSelectorReturn { checksum, } } +} + +impl From for MiiConfigIndex { + fn from(v: u32) -> Self { + Self::Index(v) + } } \ No newline at end of file