regex search/replace instances of xous_ipc::String to String

This commit is contained in:
bunnie 2024-09-22 14:26:41 +08:00
parent 0fbca1cd4d
commit b514d31fed
10 changed files with 59 additions and 57 deletions

View file

@ -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

View file

@ -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<xous_ipc::String<3000>>,
pub qrtext: Option<String>,
}
#[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<xous_ipc::String<1024>>,
pub caption: Option<String>,
}
#[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<xous_ipc::String<1024>>,
pub text: Option<xous_ipc::String<2048>>,
pub title: Option<String>,
pub text: Option<String>,
}
/// API note: enums with explicit numbers may not have their numbers re-ordered, especially

View file

@ -67,7 +67,7 @@ impl<'a> AlertModalBuilder<'a> {
pub fn build(&self) -> Result<TextEntryPayloads, xous::Error> {
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<String, 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::PromptWithFixedResponse.to_u32().unwrap())
.or(Err(xous::Error::InternalError))?;
@ -730,7 +730,7 @@ impl Modals {
pub fn get_checkbox(&self, prompt: &str) -> Result<Vec<String>, 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())

View file

@ -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,

View file

@ -200,10 +200,10 @@ fn clifford() -> Img {
Img::new(buf, WIDTH.try_into().unwrap(), PixelType::U8)
}
fn test_validator(input: TextEntryPayload) -> Option<xous_ipc::String<256>> {
fn test_validator(input: TextEntryPayload) -> Option<String> {
let text_str = input.as_str();
match text_str.parse::<u32>() {
Ok(_input_int) => None,
_ => return Some(xous_ipc::String::<256>::from_str("enter an integer value")),
_ => return Some(String::from("enter an integer value")),
}
}

View file

@ -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 }

View file

@ -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)]

View file

@ -650,7 +650,7 @@ pub(crate) fn connection_manager(sid: xous::SID, activity_interval: Arc<AtomicU3
sorted_ssids.sort_unstable();
for (strongest_ssids, ret_list_item) in sorted_ssids.iter().zip(ret_list.list.iter_mut()) {
*ret_list_item = Some(SsidRecord {
name: xous_ipc::String::<32>::from_str(&strongest_ssids.ssid),
name: String::from(&strongest_ssids.ssid),
rssi: strongest_ssids.rssi,
});
}

View file

@ -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

View file

@ -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::<TrngBuf, _>().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) {