aboutsummaryrefslogtreecommitdiffstats
path: root/src/path.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/path.rs')
-rw-r--r--src/path.rs18
1 files changed, 8 insertions, 10 deletions
diff --git a/src/path.rs b/src/path.rs
index 9cb499a..a2eb1c9 100644
--- a/src/path.rs
+++ b/src/path.rs
@@ -1,11 +1,7 @@
-use std::fmt::{Debug, Display};
use bytes::Bytes;
-use structdiff::{Difference, StructDiff};
use crate::packet_content::PeerToPeerCipher;
-
-#[derive(PartialEq, Debug, Clone, Difference)]
-#[difference(expose)]
+#[derive(PartialEq, Debug, Clone)]
pub struct Path {
pub cipher: PeerToPeerCipher,
}
@@ -18,21 +14,22 @@ impl From<Bytes> for Path {
}
}
-impl Display for Path {
- fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
+impl core::fmt::Display for Path {
+ fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
f.write_fmt(format_args!("({:2x?}) -> ({:2x?}) MAC: {:4x?} ", self.cipher.source, self.cipher.destination, self.cipher.mac))
}
}
+// Tests for std operations
#[cfg(test)]
mod tests {
- use std::str::FromStr;
+ use core::str::FromStr;
use hex::decode;
+ use tinyvec::array_vec;
use crate::{packet::*, packet_content::{PacketContent, PeerToPeerCipher}};
use super::*;
-
#[test]
fn path() {
let sample = "2107BA03127F7EA9221351768DD2DF32E1D02F5851379F5AFCC667AB273442FAB2943673F26DDBEB9595027474";
@@ -40,7 +37,7 @@ mod tests {
let lhs_packet = Packet {
route_type: RouteType::Flood,
version: PayloadVersion::VersionOne,
- path: vec![0xBA, 0x03, 0x12, 0x7F, 0x7E, 0xA9, 0x22],
+ path: array_vec!([u16; 64] => 0xBA, 0x03, 0x12, 0x7F, 0x7E, 0xA9, 0x22),
transport: [0, 0],
raw_content: Bytes::copy_from_slice(&decode("1351768DD2DF32E1D02F5851379F5AFCC667AB273442FAB2943673F26DDBEB9595027474").unwrap()),
content: PacketContent::Path(Path {
@@ -58,6 +55,7 @@ mod tests {
let rhs_packet = Packet::from_str(sample).unwrap();
assert_eq!(lhs_packet, rhs_packet);
+ #[cfg(feature = "std")]
assert_eq!(format!("{}", lhs_packet), " Flood | v1 | | [ba, 03, ... a9, 22] | | PATH | (51) -> (13) MAC: 768d ");
}
} \ No newline at end of file