update the skeleton to the more recent practices

This commit is contained in:
bunnie 2022-04-08 01:33:31 +08:00
parent d49c35dc0c
commit bc55e7db5f

View file

@ -1,6 +1,7 @@
#![cfg_attr(target_os = "none", no_std)] #![cfg_attr(target_os = "none", no_std)]
pub mod api; pub mod api;
pub use api::*;
use xous::{CID, send_message}; use xous::{CID, send_message};
use num_traits::ToPrimitive; use num_traits::ToPrimitive;
@ -8,12 +9,13 @@ pub struct Codec {
conn: CID, conn: CID,
} }
impl Codec { impl Codec {
pub fn new(xns: &xous_names::XousNames) -> Result<Self, xous::Error> { pub fn new() -> Self {
let xns = xous_names::XousNames::new().expect("couldn't connect to XousNames");
REFCOUNT.fetch_add(1, Ordering::Relaxed); REFCOUNT.fetch_add(1, Ordering::Relaxed);
let conn = xns.request_connection_blocking(api::SERVER_NAME_CODEC).expect("Can't connect to Codec server"); let conn = xns.request_connection_blocking(api::SERVER_NAME_CODEC).expect("Can't connect to Codec server");
Ok(Codec { Codec {
conn conn
}) }
} }
} }