Browse Source

Implement "Srv" struct.

pull/10/head
Ronald Kinard 9 years ago
parent
commit
f822099d40
  1. 3
      src/lib.rs
  2. 4
      src/raw/srv.rs
  3. 27
      src/srv.rs

3
src/lib.rs

@ -13,6 +13,9 @@ pub mod srv;
pub mod gfx; pub mod gfx;
pub mod services; pub mod services;
pub use srv::Srv;
pub use gfx::Gfx;
#[lang = "stack_exhausted"] extern fn stack_exhausted() {} #[lang = "stack_exhausted"] extern fn stack_exhausted() {}
#[lang = "eh_personality"] extern fn eh_personality() {} #[lang = "eh_personality"] extern fn eh_personality() {}
#[lang = "panic_fmt"] fn panic_fmt() -> ! { loop {} } #[lang = "panic_fmt"] fn panic_fmt() -> ! { loop {} }

4
src/raw/srv.rs

@ -1,5 +1,5 @@
use super::*; use ::raw::*;
use super::super::{Result, Handle}; use ::{Result, Handle};
extern "C" { extern "C" {
pub fn srvInit() -> Result; pub fn srvInit() -> Result;

27
src/srv.rs

@ -1,13 +1,26 @@
use ::Result; use ::raw::srv::*;
use ::raw::srv;
pub fn init() -> Result { use core::marker::PhantomData;
pub struct Srv {
pd: PhantomData<i32>
}
impl Srv {
pub fn new() -> Result<Srv, i32> {
unsafe { unsafe {
return srv::srvInit(); let r = srvInit();
if r < 0 {
Err(r)
} else {
Ok(Srv { pd: PhantomData })
}
}
} }
} }
pub fn exit() -> Result {
unsafe { impl Drop for Srv {
return srv::srvExit(); fn drop(&mut self) {
unsafe { srvExit() };
} }
} }

Loading…
Cancel
Save