fix Copy derive and related issues in net

This commit is contained in:
bunnie 2024-09-22 21:55:20 +08:00
parent e423bfd347
commit 95a31a369c
5 changed files with 8 additions and 8 deletions

View file

@ -375,7 +375,7 @@ pub enum ScanState {
/// Indicates that the wifi susbsystem is off /// Indicates that the wifi susbsystem is off
Off, Off,
} }
#[derive(Debug, Archive, Serialize, Deserialize, Copy, Clone, Default)] #[derive(Debug, Archive, Serialize, Deserialize, Clone, Default)]
pub(crate) struct SsidList { pub(crate) struct SsidList {
/// IPC memory structures have to pre-allocate all their memory, but are always allocated in 4096-byte /// IPC memory structures have to pre-allocate all their memory, but are always allocated in 4096-byte
/// chunks. We could allocate up to maybe 100+ return values, but then we'd have to write a default /// chunks. We could allocate up to maybe 100+ return values, but then we'd have to write a default

View file

@ -22,7 +22,7 @@ pub enum NetPingCallback {
} }
//////// Intra-crate Ping structures //////// Intra-crate Ping structures
#[derive(Debug, Archive, Serialize, Deserialize, Copy, Clone)] #[derive(Debug, Archive, Serialize, Deserialize, Clone)]
pub(crate) struct NetPingPacket { pub(crate) struct NetPingPacket {
/// the address we are pinging /// the address we are pinging
pub endpoint: NetIpAddr, pub endpoint: NetIpAddr,

View file

@ -19,7 +19,7 @@ use std::net::{IpAddr, Ipv4Addr, Ipv6Addr, SocketAddr};
use rkyv::{Archive, Deserialize, Serialize}; use rkyv::{Archive, Deserialize, Serialize};
use smoltcp::wire::IpAddress; use smoltcp::wire::IpAddress;
#[derive(Debug, Archive, Serialize, Deserialize, Copy, Clone)] #[derive(Debug, Archive, Serialize, Deserialize, Clone)]
pub enum XousServerId { pub enum XousServerId {
/// A SID that is shared directly with the Net crate; a private, single-use SID for best security /// A SID that is shared directly with the Net crate; a private, single-use SID for best security
PrivateSid([u32; 4]), PrivateSid([u32; 4]),

View file

@ -184,7 +184,7 @@ impl NetManager {
let mut ret = Vec::<SsidRecord>::new(); let mut ret = Vec::<SsidRecord>::new();
for maybe_item in ssid_list.list.iter() { for maybe_item in ssid_list.list.iter() {
if let Some(item) = maybe_item { if let Some(item) = maybe_item {
ret.push(*item); ret.push(item.clone());
} }
} }
Ok((ret, ssid_list.state)) Ok((ret, ssid_list.state))

View file

@ -81,11 +81,11 @@ impl Ping {
/// Send a single ping immediately, with the result going to an asynchronous callback /// Send a single ping immediately, with the result going to an asynchronous callback
pub fn ping(&self, remote: IpAddr) -> bool { pub fn ping(&self, remote: IpAddr) -> bool {
if let Some(cbs) = self.callback_server { if let Some(cbs) = self.callback_server.as_ref() {
if let Some(dispatch_op) = self.dispatch_opcode { if let Some(dispatch_op) = self.dispatch_opcode {
let ping = NetPingPacket { let ping = NetPingPacket {
endpoint: NetIpAddr::from(remote), endpoint: NetIpAddr::from(remote),
server: cbs, server: cbs.clone(),
return_opcode: dispatch_op, return_opcode: dispatch_op,
sent_ok: None, sent_ok: None,
}; };
@ -113,7 +113,7 @@ impl Ping {
/// Send multiple pings by spawning a helper thread. Results go to the asynchronous callback /// Send multiple pings by spawning a helper thread. Results go to the asynchronous callback
/// specified during the creation of the Ping object. /// specified during the creation of the Ping object.
pub fn ping_spawn_thread(&self, remote: IpAddr, count: usize, delay_ms: usize) -> Option<JoinHandle<()>> { pub fn ping_spawn_thread(&self, remote: IpAddr, count: usize, delay_ms: usize) -> Option<JoinHandle<()>> {
if let Some(cbs) = self.callback_server { if let Some(cbs) = &self.callback_server {
if let Some(dispatch_op) = self.dispatch_opcode { if let Some(dispatch_op) = self.dispatch_opcode {
let handle = thread::spawn({ let handle = thread::spawn({
let cbs = cbs.clone(); let cbs = cbs.clone();
@ -125,7 +125,7 @@ impl Ping {
while cur_count < count { while cur_count < count {
let ping = NetPingPacket { let ping = NetPingPacket {
endpoint: NetIpAddr::from(remote), endpoint: NetIpAddr::from(remote),
server: cbs, server: cbs.clone(),
return_opcode: dispatch_op, return_opcode: dispatch_op,
sent_ok: None, sent_ok: None,
}; };