diff --git a/services/shell/src/main.rs b/services/shell/src/main.rs index c63dfb1e5..678aa90bd 100644 --- a/services/shell/src/main.rs +++ b/services/shell/src/main.rs @@ -356,7 +356,7 @@ fn shell_main() -> ! { let registration = Registration::new(); let mut sendable_registration = Sendable::new(registration) .expect("can't create sendable registration structure"); - write!(sendable_registration.name, "A test Name!"); + write!(sendable_registration.name, "A test Name!").unwrap(); info!("namserver registration input: {:?}", sendable_registration.success); sendable_registration.lend_mut(ns_conn, sendable_registration.mid()).expect("nameserver registration failure!"); info!("nameserver registration result: {:?}, {:?}", sendable_registration.success, sendable_registration.sid); @@ -367,7 +367,7 @@ fn shell_main() -> ! { let mut sendable_lookup = Sendable::new(lookup) .expect("can't create sendable lookup structure"); info!("making a test name"); - write!(sendable_lookup.name, "A test Name!"); + write!(sendable_lookup.name, "A test Name!").unwrap(); info!("nameserver lookup input: {:?}", sendable_lookup.success); sendable_lookup.lend_mut(ns_conn, sendable_lookup.mid()).expect("nameserver lookup failure!"); info!("nameserver lookup result: {:?}, {:?}", sendable_lookup.success, sendable_lookup.cid); diff --git a/services/xous-names/src/api.rs b/services/xous-names/src/api.rs index c7c788c97..2377bfe37 100644 --- a/services/xous-names/src/api.rs +++ b/services/xous-names/src/api.rs @@ -1,7 +1,7 @@ #![allow(dead_code)] use xous::{SID, CID}; -use hash32_derive::*; +use hash32::{Hash, Hasher}; use core::cmp::Eq; @@ -13,13 +13,23 @@ pub const AUTHENTICATE_TIMEOUT: usize = 10_000; // time in ms that a process has //////////////////////// handle throwing strings across IPC boundary with hash comparison -#[derive(Hash32, Debug, Copy, Clone)] +#[derive(Debug, Copy, Clone)] #[repr(C)] pub struct XousServerName { - pub name: [u8; 32], + pub name: [u8; 64], pub length: usize, } +impl hash32::Hash for XousServerName { + fn hash(&self, state: &mut H) + where + H: Hasher, + { + Hash::hash(&self.name[..], state); + Hash::hash(&self.length, state) + } +} + impl XousServerName { pub fn new() -> Self { Default::default() @@ -36,7 +46,7 @@ impl XousServerName { impl Default for XousServerName { fn default() -> Self { XousServerName { - name: [0; 32], + name: [0; 64], length: 0, } } diff --git a/services/xous-names/src/lib.rs b/services/xous-names/src/lib.rs index 1be5573f9..f488b855e 100644 --- a/services/xous-names/src/lib.rs +++ b/services/xous-names/src/lib.rs @@ -11,9 +11,7 @@ Calls are made using the xous::ipc::Sendable IPC wrapper, for example: let mut sendable_registration = Sendable::new(registration) .expect("can't create sendable registration structure"); - let test_name = b"A test Name!"; - sendable_registration.name[..test_name.len()].clone_from_slice(test_name); - sendable_registration.name_len = test_name.len(); + write!(sendable_registration.name, "I'm a server, call me Fred!"); sendable_registration.lend_mut(ns_conn, sendable_registration.mid()); diff --git a/services/xous-names/src/main.rs b/services/xous-names/src/main.rs index b17dad446..f4f032526 100644 --- a/services/xous-names/src/main.rs +++ b/services/xous-names/src/main.rs @@ -6,8 +6,7 @@ extern crate hash32_derive; mod api; use api::*; -use heapless::String; -use heapless::Vec; +// use heapless::String; use heapless::FnvIndexMap; use heapless::consts::*;