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 {
|
2021-04-26 16:53:08 +00:00
|
|
|
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();}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|