if you let AI add Deserialize for everything Serialize you will have to fight this
Co-authored-by: Copilot <[email protected]>
This commit is contained in:
@@ -12,7 +12,7 @@ use crate::parse::mac;
|
||||
pub struct NeighborEntry {
|
||||
pub ip: IpAddr,
|
||||
pub dev: Option<String>,
|
||||
#[serde(with = "mac::option_mac")]
|
||||
#[serde(with = "mac::option_mac", default)]
|
||||
pub mac: Option<MacAddr>,
|
||||
pub state: NeighborState,
|
||||
}
|
||||
@@ -132,3 +132,27 @@ impl FromStr for NeighborEntry {
|
||||
parse_neighbor_line(s)
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod test {
|
||||
use super::*;
|
||||
#[test]
|
||||
fn deserialize_online_neighbor() {
|
||||
NeighborEntry::deserialize(serde_json::json!({
|
||||
"ip" : "192.168.100.94",
|
||||
"dev" : "br-lan",
|
||||
"mac" : "04:7C:16:79:6D:EE",
|
||||
"state" : "REACHABLE"
|
||||
}))
|
||||
.expect("all fields must pass");
|
||||
}
|
||||
#[test]
|
||||
fn deserialize_failed_neighbor() {
|
||||
NeighborEntry::deserialize(serde_json::json!({
|
||||
"ip" : "192.168.100.94",
|
||||
"dev" : "br-lan",
|
||||
"state" : "FAILED"
|
||||
}))
|
||||
.expect("default");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user