xous-core/services/susres/src/lib.rs

27 lines
657 B
Rust
Raw Normal View History

2021-04-26 16:38:51 +00:00
#![cfg_attr(target_os = "none", no_std)]
pub mod api;
pub use api::*;
use xous::{CID, send_message};
use num_traits::ToPrimitive;
pub struct Susres {
conn: CID,
}
impl Susres {
pub fn new(xns: &xous_names::XousNames) -> Result<Self, xous::Error> {
let conn = xns.request_connection_blocking(api::SERVER_NAME_SUSRES).expect("Can't connect to SUSRES");
2021-04-26 16:38:51 +00:00
Ok(Susres {
conn
})
}
}
impl Drop for Susres {
fn drop(&mut self) {
// de-allocate myself. It's unsafe because we are responsible to make sure nobody else is using the connection.
unsafe{xous::disconnect(self.conn).unwrap();}
}
}