fixup API to not rely on copy, instead use borrow

also some more regex fixup
This commit is contained in:
bunnie 2024-09-23 00:00:41 +08:00
parent ef718853b2
commit 8424d19ea9
2 changed files with 18 additions and 16 deletions

View file

@ -252,7 +252,7 @@ pub(crate) fn connection_manager(sid: xous::SID, activity_interval: Arc<AtomicU3
// reset the stats cache, and update subscribers that we're disconnected // reset the stats cache, and update subscribers that we're disconnected
wifi_stats_cache = WlanStatus::from_ipc(WlanStatusIpc::default()); wifi_stats_cache = WlanStatus::from_ipc(WlanStatusIpc::default());
for &sub in status_subscribers.keys() { for &sub in status_subscribers.keys() {
let buf = Buffer::into_buf(com::WlanStatusIpc::from_status(wifi_stats_cache)) let buf = Buffer::into_buf(com::WlanStatusIpc::from_status(&wifi_stats_cache))
.or(Err(xous::Error::InternalError)) .or(Err(xous::Error::InternalError))
.unwrap(); .unwrap();
match buf.send(sub, WifiStateCallback::Update.to_u32().unwrap()) { match buf.send(sub, WifiStateCallback::Update.to_u32().unwrap()) {
@ -277,7 +277,7 @@ pub(crate) fn connection_manager(sid: xous::SID, activity_interval: Arc<AtomicU3
wifi_stats_cache = WlanStatus::from_ipc(WlanStatusIpc::default()); wifi_stats_cache = WlanStatus::from_ipc(WlanStatusIpc::default());
for &sub in status_subscribers.keys() { for &sub in status_subscribers.keys() {
let buf = let buf =
Buffer::into_buf(com::WlanStatusIpc::from_status(wifi_stats_cache)) Buffer::into_buf(com::WlanStatusIpc::from_status(&wifi_stats_cache))
.or(Err(xous::Error::InternalError)) .or(Err(xous::Error::InternalError))
.unwrap(); .unwrap();
match buf.send(sub, WifiStateCallback::Update.to_u32().unwrap()) { match buf.send(sub, WifiStateCallback::Update.to_u32().unwrap()) {
@ -378,7 +378,7 @@ pub(crate) fn connection_manager(sid: xous::SID, activity_interval: Arc<AtomicU3
log::debug!("stats update: {:?}", wifi_stats_cache); log::debug!("stats update: {:?}", wifi_stats_cache);
for &sub in status_subscribers.keys() { for &sub in status_subscribers.keys() {
let buf = let buf =
Buffer::into_buf(com::WlanStatusIpc::from_status(wifi_stats_cache)) Buffer::into_buf(com::WlanStatusIpc::from_status(&wifi_stats_cache))
.or(Err(xous::Error::InternalError)) .or(Err(xous::Error::InternalError))
.unwrap(); .unwrap();
match buf.send(sub, WifiStateCallback::Update.to_u32().unwrap()) { match buf.send(sub, WifiStateCallback::Update.to_u32().unwrap()) {
@ -445,9 +445,10 @@ pub(crate) fn connection_manager(sid: xous::SID, activity_interval: Arc<AtomicU3
// reset the stats cache, and update subscribers that we're disconnected // reset the stats cache, and update subscribers that we're disconnected
wifi_stats_cache = WlanStatus::from_ipc(WlanStatusIpc::default()); wifi_stats_cache = WlanStatus::from_ipc(WlanStatusIpc::default());
for &sub in status_subscribers.keys() { for &sub in status_subscribers.keys() {
let buf = Buffer::into_buf(com::WlanStatusIpc::from_status(wifi_stats_cache)) let buf =
.or(Err(xous::Error::InternalError)) Buffer::into_buf(com::WlanStatusIpc::from_status(&wifi_stats_cache))
.unwrap(); .or(Err(xous::Error::InternalError))
.unwrap();
match buf.send(sub, WifiStateCallback::Update.to_u32().unwrap()) { match buf.send(sub, WifiStateCallback::Update.to_u32().unwrap()) {
Err(e) => log::warn!("Couldn't update wifi state subscriber: {:?}", e), Err(e) => log::warn!("Couldn't update wifi state subscriber: {:?}", e),
_ => (), _ => (),
@ -561,7 +562,7 @@ pub(crate) fn connection_manager(sid: xous::SID, activity_interval: Arc<AtomicU3
log::debug!("stats update: {:?}", wifi_stats_cache); log::debug!("stats update: {:?}", wifi_stats_cache);
for &sub in status_subscribers.keys() { for &sub in status_subscribers.keys() {
let buf = Buffer::into_buf(com::WlanStatusIpc::from_status( let buf = Buffer::into_buf(com::WlanStatusIpc::from_status(
wifi_stats_cache, &wifi_stats_cache,
)) ))
.or(Err(xous::Error::InternalError)) .or(Err(xous::Error::InternalError))
.unwrap(); .unwrap();
@ -597,9 +598,10 @@ pub(crate) fn connection_manager(sid: xous::SID, activity_interval: Arc<AtomicU3
ssid_stats.rssi = rssi_u8; ssid_stats.rssi = rssi_u8;
log::debug!("stats update: {:?}", wifi_stats_cache); log::debug!("stats update: {:?}", wifi_stats_cache);
for &sub in status_subscribers.keys() { for &sub in status_subscribers.keys() {
let buf = Buffer::into_buf(com::WlanStatusIpc::from_status(wifi_stats_cache)) let buf =
.or(Err(xous::Error::InternalError)) Buffer::into_buf(com::WlanStatusIpc::from_status(&wifi_stats_cache))
.unwrap(); .or(Err(xous::Error::InternalError))
.unwrap();
match buf.send(sub, WifiStateCallback::Update.to_u32().unwrap()) { match buf.send(sub, WifiStateCallback::Update.to_u32().unwrap()) {
Err(e) => log::warn!("Couldn't update wifi state subscriber: {:?}", e), Err(e) => log::warn!("Couldn't update wifi state subscriber: {:?}", e),
_ => (), _ => (),
@ -720,7 +722,7 @@ pub(crate) fn connection_manager(sid: xous::SID, activity_interval: Arc<AtomicU3
}; };
log::debug!("stats update: {:?}", wifi_stats_cache); log::debug!("stats update: {:?}", wifi_stats_cache);
for &sub in status_subscribers.keys() { for &sub in status_subscribers.keys() {
let buf = Buffer::into_buf(com::WlanStatusIpc::from_status(wifi_stats_cache)) let buf = Buffer::into_buf(com::WlanStatusIpc::from_status(&wifi_stats_cache))
.or(Err(xous::Error::InternalError)) .or(Err(xous::Error::InternalError))
.unwrap(); .unwrap();
match buf.send(sub, WifiStateCallback::Update.to_u32().unwrap()) { match buf.send(sub, WifiStateCallback::Update.to_u32().unwrap()) {
@ -756,7 +758,7 @@ pub(crate) fn connection_manager(sid: xous::SID, activity_interval: Arc<AtomicU3
}; };
log::debug!("stats update: {:?}", wifi_stats_cache); log::debug!("stats update: {:?}", wifi_stats_cache);
for &sub in status_subscribers.keys() { for &sub in status_subscribers.keys() {
let buf = Buffer::into_buf(com::WlanStatusIpc::from_status(wifi_stats_cache)) let buf = Buffer::into_buf(com::WlanStatusIpc::from_status(&wifi_stats_cache))
.or(Err(xous::Error::InternalError)) .or(Err(xous::Error::InternalError))
.unwrap(); .unwrap();
match buf.send(sub, WifiStateCallback::Update.to_u32().unwrap()) { match buf.send(sub, WifiStateCallback::Update.to_u32().unwrap()) {
@ -795,7 +797,7 @@ pub(crate) fn connection_manager(sid: xous::SID, activity_interval: Arc<AtomicU3
}; };
log::debug!("stats update: {:?}", wifi_stats_cache); log::debug!("stats update: {:?}", wifi_stats_cache);
for &sub in status_subscribers.keys() { for &sub in status_subscribers.keys() {
let buf = Buffer::into_buf(com::WlanStatusIpc::from_status(wifi_stats_cache)) let buf = Buffer::into_buf(com::WlanStatusIpc::from_status(&wifi_stats_cache))
.or(Err(xous::Error::InternalError)) .or(Err(xous::Error::InternalError))
.unwrap(); .unwrap();
match buf.send(sub, WifiStateCallback::Update.to_u32().unwrap()) { match buf.send(sub, WifiStateCallback::Update.to_u32().unwrap()) {

View file

@ -444,8 +444,8 @@ fn main() -> ! {
let remote = IpAddress::from(pkt.endpoint); let remote = IpAddress::from(pkt.endpoint);
// we take advantage of the fact that the same CID is always returned for repeated connect // we take advantage of the fact that the same CID is always returned for repeated connect
// requests to the same SID. // requests to the same SID.
let cid = match pkt.server { let cid = match &pkt.server {
XousServerId::PrivateSid(sid) => match xous::connect(SID::from_array(sid)) { XousServerId::PrivateSid(sid) => match xous::connect(SID::from_array(*sid)) {
Ok(cid) => cid, Ok(cid) => cid,
Err(e) => { Err(e) => {
log::error!( log::error!(
@ -455,7 +455,7 @@ fn main() -> ! {
continue; continue;
} }
}, },
XousServerId::ServerName(name) => match xns.request_connection(name.to_str()) { XousServerId::ServerName(name) => match xns.request_connection(&name) {
Ok(cid) => cid, Ok(cid) => cid,
Err(e) => { Err(e) => {
log::error!( log::error!(