Browse Source

Make TitleInfo into a AM_TitleEntry wrapper

pull/95/head
Maccraft123 2 years ago
parent
commit
9b8f4239a7
  1. 1
      ctru-rs/examples/title-info.rs
  2. 23
      ctru-rs/src/services/am.rs

1
ctru-rs/examples/title-info.rs

@ -84,7 +84,6 @@ fn main() {
Ok(info) => { Ok(info) => {
println!("Size: {} KB", info.size_bytes() / 1024); println!("Size: {} KB", info.size_bytes() / 1024);
println!("Version: 0x{:x}", info.version()); println!("Version: 0x{:x}", info.version());
println!("Type: 0x{:x}", info.type_());
} }
Err(e) => println!("Failed to get title info: {}", e), Err(e) => println!("Failed to get title info: {}", e),
} }

23
ctru-rs/src/services/am.rs

@ -4,30 +4,17 @@ use std::marker::PhantomData;
use std::mem::MaybeUninit; use std::mem::MaybeUninit;
#[derive(Copy, Clone, Debug)] #[derive(Copy, Clone, Debug)]
#[repr(C)] #[repr(transparent)]
pub struct TitleInfo { pub struct TitleInfo(ctru_sys::AM_TitleEntry);
id: u64,
size: u64,
version: u16,
pad: u16,
type_: u32,
}
// Make sure TitleInfo is correct size
const _TITLEINFO_SIZE_CHECK: [u8; 0x18] = [0; std::mem::size_of::<TitleInfo>()];
impl TitleInfo { impl TitleInfo {
pub fn id(&self) -> u64 { pub fn id(&self) -> u64 {
self.id self.0.titleID
} }
pub fn size_bytes(&self) -> u64 { pub fn size_bytes(&self) -> u64 {
self.size self.0.size
} }
pub fn version(&self) -> u16 { pub fn version(&self) -> u16 {
self.version self.0.version
}
pub fn type_(&self) -> u32 {
self.type_
} }
} }

Loading…
Cancel
Save