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

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

@ -4,30 +4,17 @@ use std::marker::PhantomData; @@ -4,30 +4,17 @@ use std::marker::PhantomData;
use std::mem::MaybeUninit;
#[derive(Copy, Clone, Debug)]
#[repr(C)]
pub struct TitleInfo {
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>()];
#[repr(transparent)]
pub struct TitleInfo(ctru_sys::AM_TitleEntry);
impl TitleInfo {
pub fn id(&self) -> u64 {
self.id
self.0.titleID
}
pub fn size_bytes(&self) -> u64 {
self.size
self.0.size
}
pub fn version(&self) -> u16 {
self.version
}
pub fn type_(&self) -> u32 {
self.type_
self.0.version
}
}

Loading…
Cancel
Save