Browse Source

Merge pull request #24 from FenrirWolf/unit_type

Make ctru-rs less spooky
pull/10/head
Ronald Kinard 8 years ago committed by GitHub
parent
commit
70bfc59aab
  1. 8
      ctru-rs/src/gfx.rs
  2. 10
      ctru-rs/src/sdmc.rs
  3. 10
      ctru-rs/src/services/apt.rs
  4. 9
      ctru-rs/src/services/fs.rs
  5. 9
      ctru-rs/src/services/hid.rs
  6. 10
      ctru-rs/src/srv.rs

8
ctru-rs/src/gfx.rs

@ -1,15 +1,11 @@
use libctru::gfx; use libctru::gfx;
use std::default::Default; use std::default::Default;
use std::marker::PhantomData;
use std::ops::Drop; use std::ops::Drop;
use services::gspgpu::FramebufferFormat; use services::gspgpu::FramebufferFormat;
pub struct Gfx { pub struct Gfx(());
// we do this to prevent people from making a Gfx struct manually
pd: PhantomData<i32>,
}
#[derive(Copy, Clone)] #[derive(Copy, Clone)]
pub enum Screen { pub enum Screen {
@ -135,7 +131,7 @@ impl Gfx {
impl Default for Gfx { impl Default for Gfx {
fn default() -> Self { fn default() -> Self {
unsafe { gfx::gfxInitDefault() }; unsafe { gfx::gfxInitDefault() };
Gfx { pd: PhantomData } Gfx(())
} }
} }

10
ctru-rs/src/sdmc.rs

@ -1,19 +1,15 @@
use std::marker::PhantomData;
use libctru::sdmc::*; use libctru::sdmc::*;
pub struct Sdmc { pub struct Sdmc(());
pd: PhantomData<i32>,
}
impl Sdmc { impl Sdmc {
pub fn init() -> ::Result<Sdmc> { pub fn init() -> ::Result<Sdmc> {
unsafe { unsafe {
let r = sdmcInit(); let r = sdmcInit();
if r < 0 { if r < 0 {
Err(::Error::from(r)) Err(r.into())
} else { } else {
Ok(Sdmc { pd: PhantomData }) Ok(Sdmc(()))
} }
} }
} }

10
ctru-rs/src/services/apt.rs

@ -1,19 +1,15 @@
use std::marker::PhantomData;
use libctru::services::apt; use libctru::services::apt;
pub struct Apt { pub struct Apt(());
pd: PhantomData<i32>
}
impl Apt { impl Apt {
pub fn init() -> ::Result<Apt> { pub fn init() -> ::Result<Apt> {
unsafe { unsafe {
let r = apt::aptInit(); let r = apt::aptInit();
if r < 0 { if r < 0 {
Err(::Error::from(r)) Err(r.into())
} else { } else {
Ok(Apt { pd: PhantomData }) Ok(Apt(()))
} }
} }
} }

9
ctru-rs/src/services/fs.rs

@ -9,7 +9,6 @@ use std::io::Result as IoResult;
use std::io::ErrorKind as IoErrorKind; use std::io::ErrorKind as IoErrorKind;
use std::ffi::OsString; use std::ffi::OsString;
use std::marker::PhantomData;
use std::ptr; use std::ptr;
use std::slice; use std::slice;
use std::mem; use std::mem;
@ -83,9 +82,7 @@ pub enum ArchiveID {
/// until an instance of this struct is created. /// until an instance of this struct is created.
/// ///
/// The service exits when all instances of this struct go out of scope. /// The service exits when all instances of this struct go out of scope.
pub struct Fs { pub struct Fs(());
pd: PhantomData<i32>,
}
/// Handle to an open filesystem archive. /// Handle to an open filesystem archive.
/// ///
@ -304,9 +301,9 @@ impl Fs {
unsafe { unsafe {
let r = fsInit(); let r = fsInit();
if r < 0 { if r < 0 {
Err(::Error::from(r)) Err(r.into())
} else { } else {
Ok(Fs { pd: PhantomData }) Ok(Fs(()))
} }
} }
} }

9
ctru-rs/src/services/hid.rs

@ -1,5 +1,4 @@
use std::convert::Into; use std::convert::Into;
use std::marker::PhantomData;
use libctru::services::hid; use libctru::services::hid;
@ -73,18 +72,16 @@ impl From<PadKey> for u32 {
} }
} }
pub struct Hid { pub struct Hid(());
pd: PhantomData<i32>
}
impl Hid { impl Hid {
pub fn init() -> ::Result<Hid> { pub fn init() -> ::Result<Hid> {
unsafe { unsafe {
let r = hid::hidInit(); let r = hid::hidInit();
if r < 0 { if r < 0 {
Err(::Error::from(r)) Err(r.into())
} else { } else {
Ok(Hid { pd: PhantomData }) Ok(Hid(()))
} }
} }
} }

10
ctru-rs/src/srv.rs

@ -1,19 +1,15 @@
use libctru::srv::*; use libctru::srv::*;
use std::marker::PhantomData; pub struct Srv(());
pub struct Srv {
pd: PhantomData<i32>,
}
impl Srv { impl Srv {
pub fn init() -> ::Result<Srv> { pub fn init() -> ::Result<Srv> {
unsafe { unsafe {
let r = srvInit(); let r = srvInit();
if r < 0 { if r < 0 {
Err(::Error::from(r)) Err(r.into())
} else { } else {
Ok(Srv { pd: PhantomData }) Ok(Srv(()))
} }
} }
} }

Loading…
Cancel
Save