Browse Source

Add Sdmc struct.

This won't be useful until we have libstd, but worth making since
it's trivial.
pull/10/head
Ronald Kinard 9 years ago
parent
commit
d0bfb6a437
  1. 3
      src/lib.rs
  2. 28
      src/sdmc.rs

3
src/lib.rs

@ -11,10 +11,13 @@ pub type Handle = u32; @@ -11,10 +11,13 @@ pub type Handle = u32;
pub mod srv;
pub mod gfx;
pub mod sdmc;
pub mod services;
pub use srv::Srv;
pub use gfx::Gfx;
pub use sdmc::Sdmc;
#[lang = "stack_exhausted"] extern fn stack_exhausted() {}
#[lang = "eh_personality"] extern fn eh_personality() {}

28
src/sdmc.rs

@ -0,0 +1,28 @@ @@ -0,0 +1,28 @@
use core::marker::PhantomData;
use ::raw::sdmc::*;
pub struct Sdmc {
pd: PhantomData<i32>
}
impl Sdmc {
pub fn new() -> Result<Self, i32> {
unsafe {
let r = sdmcInit();
if r < 0 {
Err(r)
} else {
Ok(Sdmc { pd: PhantomData })
}
}
}
}
impl Drop for Sdmc {
fn drop(&mut self) {
unsafe {
sdmcExit()
};
}
}
Loading…
Cancel
Save