From 1d9316f9cdc0cca4436fa74bcc20f5832b89a6ed Mon Sep 17 00:00:00 2001 From: bunnie Date: Sun, 22 Sep 2024 14:18:49 +0800 Subject: [PATCH] regex search/replace instances of xous_ipc::String to String core xous services cluster --- services/xous-log/Cargo.toml | 5 +++-- services/xous-log/src/main.rs | 16 ++++++++-------- services/xous-names/Cargo.toml | 5 +++-- services/xous-names/src/main.rs | 18 ++++++------------ services/xous-susres/Cargo.toml | 5 +++-- services/xous-ticktimer/Cargo.toml | 5 +++-- services/xous-ticktimer/src/main.rs | 2 +- 7 files changed, 27 insertions(+), 29 deletions(-) diff --git a/services/xous-log/Cargo.toml b/services/xous-log/Cargo.toml index 6fb560dee..a8af8fd45 100644 --- a/services/xous-log/Cargo.toml +++ b/services/xous-log/Cargo.toml @@ -20,8 +20,9 @@ num-traits = { version = "0.2.14", default-features = false } utralib = { version = "0.1.24", optional = true, default-features = false } # for USB serial logging -rkyv = { version = "0.4.3", default-features = false, features = [ - "const_generics", +rkyv = { version = "0.8.8", default-features = false, features = [ + "std", + "alloc", ], optional = true } cramium-hal = { path = "../../libs/cramium-hal", optional = true, default-features = false, features = [ diff --git a/services/xous-log/src/main.rs b/services/xous-log/src/main.rs index 070ed0a43..edda3335c 100644 --- a/services/xous-log/src/main.rs +++ b/services/xous-log/src/main.rs @@ -25,15 +25,15 @@ impl Default for ConnectRequest { } #[cfg(feature = "usb")] -#[derive(Debug, rkyv::Archive, rkyv::Serialize, rkyv::Deserialize, Copy, Clone)] +#[derive(Debug, rkyv::Archive, rkyv::Serialize, rkyv::Deserialize, Clone)] pub struct UsbString { - pub s: xous_ipc::String<4000>, + pub s: String, pub sent: Option, } #[cfg(feature = "usb")] fn usb_send_str(conn: xous::CID, s: &str) { - let serializer = UsbString { s: xous_ipc::String::<4000>::from_str(s), sent: None }; + let serializer = UsbString { s: String::from(s), sent: None }; let buf = xous_ipc::Buffer::into_buf(serializer).expect("usb error"); // failures to send are silent & ignored; also, this API doesn't block. buf.send(conn, 8192 /* LogString */).expect("usb error"); @@ -48,7 +48,7 @@ fn reader_thread(arg: usize) { let mut usb_serial: Option = None; // use a stack-allocated string to ensure no heap thrashing results from String manipulations #[cfg(feature = "usb")] - let mut usb_str = xous_ipc::String::<4000>::new(); + let mut usb_str = String::new(); println!("LOG: my PID is {}", xous::process::id()); let mut counter: usize = 0; @@ -124,21 +124,21 @@ fn reader_thread(arg: usize) { // inefficient write!(usb_str, "{}:", level).ok(); for c in module_slice { - usb_str.push_byte(*c).ok(); + usb_str.push(*c as char); } write!(usb_str, ": ").ok(); for c in args_slice { - usb_str.push_byte(*c).ok(); + usb_str.push(*c as char); } write!(usb_str, " (").ok(); for c in file_slice { - usb_str.push_byte(*c).ok(); + usb_str.push(*c as char); } if let Some(line) = lr.line { write!(usb_str, ":{}", line.get()).ok(); } writeln!(usb_str, ")").ok(); - usb_send_str(conn, usb_str.to_str()); + usb_send_str(conn, &usb_str); } } api::Opcode::StandardOutput | api::Opcode::StandardError => { diff --git a/services/xous-names/Cargo.toml b/services/xous-names/Cargo.toml index b13389b46..e2db1509f 100644 --- a/services/xous-names/Cargo.toml +++ b/services/xous-names/Cargo.toml @@ -17,8 +17,9 @@ xous-ipc = "0.9.63" num-derive = { version = "0.3.3", default-features = false } num-traits = { version = "0.2.14", default-features = false } log = "0.4.14" -rkyv = { version = "0.4.3", default-features = false, features = [ - "const_generics", +rkyv = { version = "0.8.8", default-features = false, features = [ + "std", + "alloc", ] } utralib = { version = "0.1.24", optional = true, default-features = false } diff --git a/services/xous-names/src/main.rs b/services/xous-names/src/main.rs index b25299f54..e28dbfa24 100644 --- a/services/xous-names/src/main.rs +++ b/services/xous-names/src/main.rs @@ -8,7 +8,7 @@ use num_traits::FromPrimitive; use xous::{msg_blocking_scalar_unpack, MessageEnvelope}; use xous_api_names::api::*; use xous_api_names::*; -use xous_ipc::{Buffer, String}; +use xous_ipc::Buffer; #[derive(PartialEq)] #[repr(C)] @@ -371,9 +371,7 @@ fn main() -> ! { let mem = msg.body.memory_message_mut().unwrap(); let mut buffer = unsafe { Buffer::from_memory_message_mut(mem) }; let registration = buffer.to_original::().unwrap(); - let name = XousServerName::from_str( - registration.name.as_str().expect("couldn't convert server name to string"), - ); + let name = XousServerName::from_str(registration.name.as_str()); let response: api::Return; let mut should_connect = false; @@ -462,10 +460,8 @@ fn main() -> ! { Some(api::Opcode::Lookup) => { let mem = msg.body.memory_message_mut().unwrap(); let mut buffer = unsafe { Buffer::from_memory_message_mut(mem) }; - let name_string = buffer.to_original::, _>().unwrap(); - let name = XousServerName::from_str( - name_string.as_str().expect("couldn't convert server name to string"), - ); + let name_string = buffer.to_original::().unwrap(); + let name = XousServerName::from_str(name_string.as_str()); log::trace!("Lookup request for '{}'", name); let response: api::Return; if let (Some(server_sid), token) = name_table.connect(&name) { @@ -494,9 +490,7 @@ fn main() -> ! { // here eventually. let (c1, c2, c3, c4) = xous::create_server_id().unwrap().to_u32(); let auth_request = AuthenticateRequest { - name: String::<64>::from_str( - name_string.as_str().expect("couldn't convert server name to string"), - ), + name: String::from(name_string.as_str()), pubkey_id: [0; 20], // placeholder challenge: [c1, c2, c3, c4], }; @@ -524,7 +518,7 @@ fn main() -> ! { let mem = msg.body.memory_message_mut().unwrap(); let mut buffer = unsafe { Buffer::from_memory_message_mut(mem) }; let disconnect = buffer.to_original::().unwrap(); - let name = XousServerName::from_str(disconnect.name.as_str().unwrap()); + let name = XousServerName::from_str(disconnect.name.as_str()); let response = if name_table.disconnect_with_token(&name, disconnect.token) { api::Return::Success } else { diff --git a/services/xous-susres/Cargo.toml b/services/xous-susres/Cargo.toml index aad8ffdc0..431dbd9b7 100644 --- a/services/xous-susres/Cargo.toml +++ b/services/xous-susres/Cargo.toml @@ -19,8 +19,9 @@ log = "0.4.14" num-derive = { version = "0.3.3", default-features = false } num-traits = { version = "0.2.14", default-features = false } -rkyv = { version = "0.4.3", default-features = false, features = [ - "const_generics", +rkyv = { version = "0.8.8", default-features = false, features = [ + "std", + "alloc", ] } diff --git a/services/xous-ticktimer/Cargo.toml b/services/xous-ticktimer/Cargo.toml index 49544e53c..cc0061670 100644 --- a/services/xous-ticktimer/Cargo.toml +++ b/services/xous-ticktimer/Cargo.toml @@ -17,8 +17,9 @@ xous-names = { package = "xous-api-names", version = "0.9.61" } log-server = { package = "xous-api-log", version = "0.1.59" } susres = { package = "xous-api-susres", version = "0.9.59" } log = "0.4.14" -rkyv = { version = "0.4.3", default-features = false, features = [ - "const_generics", +rkyv = { version = "0.8.8", default-features = false, features = [ + "std", + "alloc", ] } num-derive = { version = "0.3.3", default-features = false } num-traits = { version = "0.2.14", default-features = false } diff --git a/services/xous-ticktimer/src/main.rs b/services/xous-ticktimer/src/main.rs index 3957f9314..6cb23dbaf 100644 --- a/services/xous-ticktimer/src/main.rs +++ b/services/xous-ticktimer/src/main.rs @@ -212,7 +212,7 @@ fn main() -> ! { #[cfg(not(feature = "timestamp"))] { let v = crate::api::VersionString { - version: xous_ipc::String::from_str("--no-timestamp requested for build"), + version: String::from("--no-timestamp requested for build"), }; buf.replace(v).unwrap(); }