From b514d31fede3a289dfa5da2262660aaf705688e1 Mon Sep 17 00:00:00 2001 From: bunnie Date: Sun, 22 Sep 2024 14:26:41 +0800 Subject: [PATCH] regex search/replace instances of xous_ipc::String to String --- services/modals/Cargo.toml | 7 ++--- services/modals/src/api.rs | 18 ++++++------- services/modals/src/lib.rs | 32 +++++++++++------------ services/modals/src/main.rs | 36 +++++++++++++------------- services/modals/src/tests.rs | 4 +-- services/net/Cargo.toml | 8 +++--- services/net/src/api/rkyv_enum.rs | 2 +- services/net/src/connection_manager.rs | 2 +- services/trng/Cargo.toml | 5 ++-- services/trng/src/main.rs | 2 +- 10 files changed, 59 insertions(+), 57 deletions(-) diff --git a/services/modals/Cargo.toml b/services/modals/Cargo.toml index 0e6acae3c..297727218 100644 --- a/services/modals/Cargo.toml +++ b/services/modals/Cargo.toml @@ -15,9 +15,10 @@ log = "0.4.14" num-derive = { version = "0.3.3", default-features = false } num-traits = { version = "0.2.14", default-features = false } xous-ipc = "0.9.63" -rkyv = { version = "0.4.3", features = [ - "const_generics", -], default-features = false } +rkyv = { version = "0.8.8", default-features = false, features = [ + "std", + "alloc", +] } gam = { path = "../gam" } trng = { path = "../trng", optional = true } cram-hal-service = { path = "../cram-hal-service", optional = true } # provides trng for cramium-soc diff --git a/services/modals/src/api.rs b/services/modals/src/api.rs index 0513fd573..645bc272b 100644 --- a/services/modals/src/api.rs +++ b/services/modals/src/api.rs @@ -18,7 +18,7 @@ pub(crate) enum ValidationOp { #[derive(Debug, rkyv::Archive, rkyv::Serialize, rkyv::Deserialize, Copy, Clone)] pub struct ManagedPromptWithFixedResponse { pub token: [u32; 4], - pub prompt: xous_ipc::String<1024>, + pub prompt: String, } #[derive(Debug, rkyv::Archive, rkyv::Serialize, rkyv::Deserialize, Copy, Clone)] pub struct ManagedListItem { @@ -29,19 +29,19 @@ pub struct ManagedListItem { #[derive(Debug, rkyv::Archive, rkyv::Serialize, rkyv::Deserialize, Copy, Clone)] pub struct ManagedPromptWithTextResponse { pub token: [u32; 4], - pub prompt: xous_ipc::String<1024>, + pub prompt: String, pub fields: u32, /// placeholders - pub placeholders: Option<[Option<(xous_ipc::String<256>, bool)>; 10]>, + pub placeholders: Option<[Option<(String, bool)>; 10]>, pub growable: bool, } #[derive(Debug, rkyv::Archive, rkyv::Serialize, rkyv::Deserialize, Copy, Clone)] pub struct ManagedNotification { pub token: [u32; 4], - pub message: xous_ipc::String<1024>, + pub message: String, // A Type 40 (177x177) qrcode with Medium data correction can encode max 3391 alphanumeric characters - pub qrtext: Option>, + pub qrtext: Option, } #[derive(Debug, rkyv::Archive, rkyv::Serialize, rkyv::Deserialize, Copy, Clone)] @@ -49,7 +49,7 @@ pub struct ManagedBip39 { pub token: [u32; 4], pub bip39_data: [u8; 32], pub bip39_len: u32, - pub caption: Option>, + pub caption: Option, } #[derive(Debug, rkyv::Archive, rkyv::Serialize, rkyv::Deserialize, Copy, Clone)] @@ -62,7 +62,7 @@ pub struct ManagedImage { #[derive(Debug, rkyv::Archive, rkyv::Serialize, rkyv::Deserialize, Copy, Clone)] pub struct ManagedProgress { pub token: [u32; 4], - pub title: xous_ipc::String<1024>, + pub title: String, // these are automatcally turned into percentages on a scale of 0->100% /// starting quanta to track (e.g. starting sector for erase). pub start_work: u32, @@ -83,8 +83,8 @@ pub struct ManagedProgress { #[derive(Debug, rkyv::Archive, rkyv::Serialize, rkyv::Deserialize, Copy, Clone)] pub struct DynamicNotification { pub token: [u32; 4], - pub title: Option>, - pub text: Option>, + pub title: Option, + pub text: Option, } /// API note: enums with explicit numbers may not have their numbers re-ordered, especially diff --git a/services/modals/src/lib.rs b/services/modals/src/lib.rs index bfe6f9313..50864ea82 100644 --- a/services/modals/src/lib.rs +++ b/services/modals/src/lib.rs @@ -67,7 +67,7 @@ impl<'a> AlertModalBuilder<'a> { pub fn build(&self) -> Result { self.modals.lock(); - let mut final_placeholders: Option<[Option<(xous_ipc::String<256>, bool)>; 10]> = None; + let mut final_placeholders: Option<[Option<(String, bool)>; 10]> = None; let fields_amt = self.validators.len(); if fields_amt == 0 { @@ -78,7 +78,7 @@ impl<'a> AlertModalBuilder<'a> { match self.placeholders.len() { 1.. => { - let mut pl: [Option<(xous_ipc::String<256>, bool)>; 10] = Default::default(); + let mut pl: [Option<(String, bool)>; 10] = Default::default(); if fields_amt != self.placeholders.len() { log::warn!("can't have more fields than placeholders"); @@ -88,7 +88,7 @@ impl<'a> AlertModalBuilder<'a> { for (index, placeholder) in self.placeholders.iter().enumerate() { if let Some((string, persist)) = placeholder { - pl[index] = Some((xous_ipc::String::from_str(&string), *persist)) + pl[index] = Some((String::from(&string), *persist)) } else { pl[index] = None } @@ -103,7 +103,7 @@ impl<'a> AlertModalBuilder<'a> { let mut spec = ManagedPromptWithTextResponse { token: self.modals.token, - prompt: xous_ipc::String::from_str(&self.prompt), + prompt: String::from(&self.prompt), fields: fields_amt as u32, placeholders: final_placeholders, growable: self.growable, @@ -229,12 +229,12 @@ impl Modals { pub fn show_notification(&self, notification: &str, qrtext: Option<&str>) -> Result<(), xous::Error> { self.lock(); let qrtext = match qrtext { - Some(text) => Some(xous_ipc::String::from_str(text)), + Some(text) => Some(String::from(text)), None => None, }; let spec = ManagedNotification { token: self.token, - message: xous_ipc::String::from_str(notification), + message: String::from(notification), qrtext, }; let buf = Buffer::into_buf(spec).or(Err(xous::Error::InternalError))?; @@ -279,7 +279,7 @@ impl Modals { } let spec = ManagedBip39 { token: self.token, - caption: if let Some(c) = caption { Some(xous_ipc::String::from_str(c)) } else { None }, + caption: if let Some(c) = caption { Some(String::from(c)) } else { None }, bip39_data, bip39_len: if data.len() <= 32 { data.len() as u32 } else { 32 }, }; @@ -328,7 +328,7 @@ impl Modals { self.lock(); let spec = ManagedBip39 { token: self.token, - caption: if let Some(c) = prompt { Some(xous_ipc::String::from_str(c)) } else { None }, + caption: if let Some(c) = prompt { Some(String::from(c)) } else { None }, bip39_data: [0u8; 32], bip39_len: 0, }; @@ -406,7 +406,7 @@ impl Modals { self.lock(); let spec = ManagedProgress { token: self.token, - title: xous_ipc::String::from_str(title), + title: String::from(title), start_work: start, end_work: end, current_work: current, @@ -455,7 +455,7 @@ impl Modals { self.lock(); let spec = ManagedProgress { token: self.token, - title: xous_ipc::String::from_str(title), + title: String::from(title), start_work: start, end_work: end, current_work: current, @@ -644,7 +644,7 @@ impl Modals { pub fn get_radiobutton(&self, prompt: &str) -> Result { self.lock(); let spec = - ManagedPromptWithFixedResponse { token: self.token, prompt: xous_ipc::String::from_str(prompt) }; + ManagedPromptWithFixedResponse { token: self.token, prompt: String::from(prompt) }; let mut buf = Buffer::into_buf(spec).or(Err(xous::Error::InternalError))?; buf.lend_mut(self.conn, Opcode::PromptWithFixedResponse.to_u32().unwrap()) .or(Err(xous::Error::InternalError))?; @@ -730,7 +730,7 @@ impl Modals { pub fn get_checkbox(&self, prompt: &str) -> Result, xous::Error> { self.lock(); let spec = - ManagedPromptWithFixedResponse { token: self.token, prompt: xous_ipc::String::from_str(prompt) }; + ManagedPromptWithFixedResponse { token: self.token, prompt: String::from(prompt) }; let mut buf = Buffer::into_buf(spec).or(Err(xous::Error::InternalError))?; buf.lend_mut(self.conn, Opcode::PromptWithMultiResponse.to_u32().unwrap()) .or(Err(xous::Error::InternalError))?; @@ -828,8 +828,8 @@ impl Modals { self.lock(); let spec = DynamicNotification { token: self.token, - title: if let Some(t) = title { Some(xous_ipc::String::from_str(t)) } else { None }, - text: if let Some(t) = text { Some(xous_ipc::String::from_str(t)) } else { None }, + title: if let Some(t) = title { Some(String::from(t)) } else { None }, + text: if let Some(t) = text { Some(String::from(t)) } else { None }, }; let buf = Buffer::into_buf(spec).or(Err(xous::Error::InternalError))?; buf.lend(self.conn, Opcode::DynamicNotification.to_u32().unwrap()) @@ -846,8 +846,8 @@ impl Modals { ) -> Result<(), xous::Error> { let spec = DynamicNotification { token: self.token, - title: if let Some(t) = title { Some(xous_ipc::String::from_str(t)) } else { None }, - text: if let Some(t) = text { Some(xous_ipc::String::from_str(t)) } else { None }, + title: if let Some(t) = title { Some(String::from(t)) } else { None }, + text: if let Some(t) = text { Some(String::from(t)) } else { None }, }; let buf = Buffer::into_buf(spec).or(Err(xous::Error::InternalError))?; buf.lend(self.conn, Opcode::UpdateDynamicNotification.to_u32().unwrap()) diff --git a/services/modals/src/main.rs b/services/modals/src/main.rs index 8c078984a..04f962764 100644 --- a/services/modals/src/main.rs +++ b/services/modals/src/main.rs @@ -454,7 +454,7 @@ fn wrapped_main() -> ! { RendererState::RunText(config) => { log::debug!("initiating text entry modal"); #[cfg(feature = "tts")] - tts.tts_simple(config.prompt.as_str().unwrap()).unwrap(); + tts.tts_simple(config.prompt.as_str()).unwrap(); log::info!("setting growable to: {:?}", config.growable); renderer_modal.set_growable(config.growable); renderer_modal.modify( @@ -464,7 +464,7 @@ fn wrapped_main() -> ! { ta })), - Some(config.prompt.as_str().unwrap()), + Some(config.prompt.as_str()), false, None, true, @@ -478,7 +478,7 @@ fn wrapped_main() -> ! { renderer_cid, Opcode::NotificationReturn.to_u32().unwrap(), ); - let text = config.message.as_str().unwrap(); + let text = config.message.as_str(); let tmp: String; let qrtext = match config.qrtext { Some(text) => { @@ -489,7 +489,7 @@ fn wrapped_main() -> ! { }; notification.set_qrcode(qrtext); #[cfg(feature = "tts")] - tts.tts_simple(config.message.as_str().unwrap()).unwrap(); + tts.tts_simple(config.message.as_str()).unwrap(); renderer_modal.modify( Some(ActionType::Notification(notification)), Some(text), @@ -507,7 +507,7 @@ fn wrapped_main() -> ! { ); let mut text = String::new(); if let Some(c) = config.caption { - text.push_str(c.as_str().unwrap()); + text.push_str(c.as_str()); text.push_str("\n\n"); } @@ -543,7 +543,7 @@ fn wrapped_main() -> ! { ); let mut text = String::new(); if let Some(c) = config.caption { - text.push_str(c.as_str().unwrap()); + text.push_str(c.as_str()); } #[cfg(feature = "tts")] @@ -590,10 +590,10 @@ fn wrapped_main() -> ! { progress_action.set_is_progressbar(!config.user_interaction); progress_action.step = config.step; #[cfg(feature = "tts")] - tts.tts_simple(config.title.as_str().unwrap()).unwrap(); + tts.tts_simple(config.title.as_str()).unwrap(); renderer_modal.modify( Some(ActionType::Slider(progress_action)), - Some(config.title.as_str().unwrap()), + Some(config.title.as_str()), false, None, true, @@ -617,11 +617,11 @@ fn wrapped_main() -> ! { #[cfg(feature = "tts")] { tts.tts_blocking(t!("modals.radiobutton", locales::LANG)).unwrap(); - tts.tts_blocking(config.prompt.as_str().unwrap()).unwrap(); + tts.tts_blocking(config.prompt.as_str()).unwrap(); } renderer_modal.modify( Some(ActionType::RadioButtons(radiobuttons)), - Some(config.prompt.as_str().unwrap()), + Some(config.prompt.as_str()), false, None, true, @@ -644,11 +644,11 @@ fn wrapped_main() -> ! { #[cfg(feature = "tts")] { tts.tts_blocking(t!("modals.checkbox", locales::LANG)).unwrap(); - tts.tts_blocking(config.prompt.as_str().unwrap()).unwrap(); + tts.tts_blocking(config.prompt.as_str()).unwrap(); } renderer_modal.modify( Some(ActionType::CheckBoxes(checkbox)), - Some(config.prompt.as_str().unwrap()), + Some(config.prompt.as_str()), false, None, true, @@ -666,14 +666,14 @@ fn wrapped_main() -> ! { let mut top_text = String::new(); if let Some(title) = config.title { #[cfg(feature = "tts")] - tts.tts_simple(title.as_str().unwrap()).unwrap(); - top_text.push_str(title.as_str().unwrap()); + tts.tts_simple(title.as_str()).unwrap(); + top_text.push_str(title.as_str()); } let mut bot_text = String::new(); if let Some(text) = config.text { #[cfg(feature = "tts")] - tts.tts_simple(text.as_str().unwrap()).unwrap(); - bot_text.push_str(text.as_str().unwrap()); + tts.tts_simple(text.as_str()).unwrap(); + bot_text.push_str(text.as_str()); } let mut gutter = gam::modal::Notification::new( renderer_cid, @@ -719,11 +719,11 @@ fn wrapped_main() -> ! { //renderer_modal.gam.set_debug_level(log::LevelFilter::Debug); let mut top_text = String::new(); if let Some(title) = config.title { - top_text.push_str(title.as_str().unwrap()); + top_text.push_str(title.as_str()); } let mut bot_text = String::new(); if let Some(text) = config.text { - bot_text.push_str(text.as_str().unwrap()); + bot_text.push_str(text.as_str()); } renderer_modal.modify( None, diff --git a/services/modals/src/tests.rs b/services/modals/src/tests.rs index df60d45fd..52359b3d9 100644 --- a/services/modals/src/tests.rs +++ b/services/modals/src/tests.rs @@ -200,10 +200,10 @@ fn clifford() -> Img { Img::new(buf, WIDTH.try_into().unwrap(), PixelType::U8) } -fn test_validator(input: TextEntryPayload) -> Option> { +fn test_validator(input: TextEntryPayload) -> Option { let text_str = input.as_str(); match text_str.parse::() { Ok(_input_int) => None, - _ => return Some(xous_ipc::String::<256>::from_str("enter an integer value")), + _ => return Some(String::from("enter an integer value")), } } diff --git a/services/net/Cargo.toml b/services/net/Cargo.toml index f2203effb..f81465625 100644 --- a/services/net/Cargo.toml +++ b/services/net/Cargo.toml @@ -16,10 +16,10 @@ log = "0.4.14" num-derive = { version = "0.3.3", default-features = false } num-traits = { version = "0.2.14", default-features = false } susres = { package = "xous-api-susres", version = "0.9.59" } -#rkyv = "0.7.18" -rkyv = { version = "0.4.3", features = [ - "const_generics", -], default-features = false } +rkyv = { version = "0.8.8", default-features = false, features = [ + "std", + "alloc", +] } llio = { path = "../llio" } com = { path = "../com" } byteorder = { version = "1.0", default-features = false } diff --git a/services/net/src/api/rkyv_enum.rs b/services/net/src/api/rkyv_enum.rs index 4f11af08d..7e566b503 100644 --- a/services/net/src/api/rkyv_enum.rs +++ b/services/net/src/api/rkyv_enum.rs @@ -25,7 +25,7 @@ pub enum XousServerId { PrivateSid([u32; 4]), /// A name that needs to be looked up with XousNames. Easier to implement, but less secure as it requires /// an open connection slot that could be abused by other processes. - ServerName(xous_ipc::String<64>), + ServerName(String), } #[derive(Debug, Archive, Serialize, Deserialize, Copy, Clone, PartialEq, Eq)] diff --git a/services/net/src/connection_manager.rs b/services/net/src/connection_manager.rs index 1daa38584..1d974f94d 100644 --- a/services/net/src/connection_manager.rs +++ b/services/net/src/connection_manager.rs @@ -650,7 +650,7 @@ pub(crate) fn connection_manager(sid: xous::SID, activity_interval: Arc::from_str(&strongest_ssids.ssid), + name: String::from(&strongest_ssids.ssid), rssi: strongest_ssids.rssi, }); } diff --git a/services/trng/Cargo.toml b/services/trng/Cargo.toml index ef5cc5560..107052cb1 100644 --- a/services/trng/Cargo.toml +++ b/services/trng/Cargo.toml @@ -15,8 +15,9 @@ log = "0.4.14" num-derive = { version = "0.4.1", default-features = false } num-traits = { version = "0.2.14", default-features = false } susres = { package = "xous-api-susres", version = "0.9.59" } -rkyv = { version = "0.4.3", default-features = false, features = [ - "const_generics", +rkyv = { version = "0.8.8", default-features = false, features = [ + "std", + "alloc", ] } xous-ipc = "0.9.63" rand_core = "0.6.4" # the 0.6.4 API is necessary for compatibility with curve25519-dalek crates diff --git a/services/trng/src/main.rs b/services/trng/src/main.rs index 7bbaddd20..b6788e2dd 100644 --- a/services/trng/src/main.rs +++ b/services/trng/src/main.rs @@ -701,7 +701,7 @@ fn main() -> ! { let mut buffer = unsafe { Buffer::from_memory_message_mut(msg.body.memory_message_mut().unwrap()) }; let len = buffer.as_flat::().unwrap().len; - buffer.replace(trng.get_buf(len)).unwrap(); + buffer.replace(trng.get_buf(len.into())).unwrap(); } Some(api::Opcode::TestSetMode) => xous::msg_blocking_scalar_unpack!(msg, mode_code, _, _, _, { if let Some(mode) = FromPrimitive::from_usize(mode_code) {