diff --git a/services/rkyv-test-server/src/main.rs b/services/rkyv-test-server/src/main.rs index 34dfe1870..8b800593f 100644 --- a/services/rkyv-test-server/src/main.rs +++ b/services/rkyv-test-server/src/main.rs @@ -100,7 +100,8 @@ fn test_main() -> ! { "Hello, world! This is the server, PID {}", xous::current_pid().unwrap() ); - let sid = xous_names::register_name(api::SERVER_NAME).unwrap(); + let xns = xous_names::XousNames::new().unwrap(); + let sid = xns.register_name(api::SERVER_NAME).unwrap(); let mut logstring_callback_connections = [None; 32]; diff --git a/services/xous-names/src/api.rs b/services/xous-names/src/api.rs index 6a61fceea..5c1eab1db 100644 --- a/services/xous-names/src/api.rs +++ b/services/xous-names/src/api.rs @@ -1,5 +1,6 @@ use hash32::{Hash, Hasher}; +#[allow(dead_code)] pub const AUTHENTICATE_TIMEOUT: u32 = 10_000; // time in ms that a process has to respond to an authentication request #[derive(num_derive::FromPrimitive, num_derive::ToPrimitive)] @@ -60,6 +61,7 @@ impl Default for XousServerName { } } +#[allow(dead_code)] impl XousServerName { pub fn to_str(&self) -> &str { core::str::from_utf8(unsafe { diff --git a/services/xous-names/src/lib.rs b/services/xous-names/src/lib.rs index 539bf3043..e4126d9dc 100644 --- a/services/xous-names/src/lib.rs +++ b/services/xous-names/src/lib.rs @@ -4,7 +4,7 @@ pub mod api; use core::fmt::Write; use xous_ipc::{String, Buffer}; -use num_traits::{FromPrimitive, ToPrimitive}; +use num_traits::ToPrimitive; pub struct XousNames { conn: xous::CID, diff --git a/services/xous-names/src/main.rs b/services/xous-names/src/main.rs index f5efe941c..5887e5a3d 100644 --- a/services/xous-names/src/main.rs +++ b/services/xous-names/src/main.rs @@ -10,8 +10,7 @@ use api::*; use heapless::consts::*; use heapless::FnvIndexMap; -use core::convert::TryInto; -use num_traits::{FromPrimitive, ToPrimitive}; +use num_traits::FromPrimitive; use xous_ipc::{String, Buffer}; use log::{error, info}; @@ -39,12 +38,12 @@ fn xmain() -> ! { if debug1{info!("NS: received message");} match FromPrimitive::from_usize(msg.body.id()) { Some(api::Opcode::Register) => { - let mut mem = msg.body.memory_message_mut().unwrap(); + let mem = msg.body.memory_message_mut().unwrap(); let mut buffer = unsafe { Buffer::from_memory_message_mut(mem) }; - let xous_string = buffer.try_into::, _>().unwrap(); - let name = XousServerName::from_str(xous_string.as_str().unwrap()); + let xous_string = buffer.try_into::, _>().unwrap(); + let name = XousServerName::from_str(xous_string.as_str()); - let mut response: api::Return; + let response: api::Return; if debug1{info!("NS: registration request for '{}'", name);} if !name_table.contains_key(&name) { @@ -72,12 +71,12 @@ fn xmain() -> ! { buffer.serialize_from(response).unwrap(); } Some(api::Opcode::Lookup) => { - let mut mem = msg.body.memory_message_mut().unwrap(); + let mem = msg.body.memory_message_mut().unwrap(); let mut buffer = unsafe { Buffer::from_memory_message_mut(mem) }; - let name_string = buffer.try_into::, _>().unwrap(); - let name = XousServerName::from_str(name_string.as_str().unwrap()); + let name_string = buffer.try_into::, _>().unwrap(); + let name = XousServerName::from_str(name_string.as_str()); if debug1{info!("NS: Lookup request for '{}'", name);} - let mut response: api::Return; + let response: api::Return; if let Some(server_sid) = name_table.get(&name) { let sender_pid = msg .sender @@ -112,7 +111,7 @@ fn xmain() -> ! { // no authenticate remedy currently supported, but we'd put that code somewhere around here eventually. let (c1, c2, c3, c4) = xous::create_server_id().unwrap().to_u32(); let auth_request = AuthenticateRequest { - name: name_string, + name: String::<64>::from_str(name_string.as_str()), pubkey_id: [0; 20], // placeholder challenge: [c1, c2, c3, c4], }; @@ -121,9 +120,9 @@ fn xmain() -> ! { buffer.serialize_from(response).unwrap(); } Some(api::Opcode::AuthenticatedLookup) => { - let mut mem = msg.body.memory_message_mut().unwrap(); + let mem = msg.body.memory_message_mut().unwrap(); let buffer = unsafe { Buffer::from_memory_message_mut(mem) }; - let auth_lookup = buffer.try_into::().unwrap(); + let auth_lookup: AuthenticatedLookup = buffer.deserialize().unwrap(); info!("NS: AuthenticatedLookup request {:?}", auth_lookup); error!("NS: AuthenticatedLookup not yet implemented"); unimplemented!("NS: AuthenticatedLookup not yet implemented");