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

core xous services cluster
This commit is contained in:
bunnie 2024-09-22 14:18:49 +08:00
parent 916c98fd5c
commit 1d9316f9cd
7 changed files with 27 additions and 29 deletions

View file

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

View file

@ -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<u32>,
}
#[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<xous::CID> = 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 => {

View file

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

View file

@ -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::<Registration, _>().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::<String<64>, _>().unwrap();
let name = XousServerName::from_str(
name_string.as_str().expect("couldn't convert server name to string"),
);
let name_string = buffer.to_original::<String, _>().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::<Disconnect, _>().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 {

View file

@ -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",
] }

View file

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

View file

@ -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();
}