From bf21ebaaae44b267cfefc87eee9608c09aab96b7 Mon Sep 17 00:00:00 2001 From: Will Dillon Date: Thu, 4 Dec 2025 17:07:12 +0000 Subject: Getting closer to no-std being done --- src/ack.rs | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) (limited to 'src/ack.rs') diff --git a/src/ack.rs b/src/ack.rs index 7b30205..236ddc4 100644 --- a/src/ack.rs +++ b/src/ack.rs @@ -1,10 +1,7 @@ -use std::fmt::Display; use bytes::{Buf, Bytes}; -use structdiff::{Difference, StructDiff}; -#[derive(PartialEq, Debug, Clone, Difference)] -#[difference(expose)] +#[derive(PartialEq, Debug, Clone)] pub struct Ack { checksum: u32 } @@ -16,17 +13,18 @@ impl From for Ack { } } -impl Display for Ack { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { +impl core::fmt::Display for Ack { + fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { f.write_fmt(format_args!("Checksum: {:4x?}", self.checksum)) } } #[cfg(test)] mod tests { - use std::str::FromStr; + use core::str::FromStr; use hex::decode; use bytes::Bytes; + use tinyvec::array_vec; use crate::{ack::Ack, packet::*, packet_content::PacketContent}; #[test] @@ -36,7 +34,7 @@ mod tests { let lhs_packet = Packet { route_type: RouteType::Flood, version: PayloadVersion::VersionOne, - path: vec![0x78, 0xB5, 0x56, 0x1B, 0x03, 0xCD, 0x70, 0xDA, 0x32, 0x60, 0x66, 0xB8, 0xA0, 0xCF], + path: array_vec!([u16; 64] => 0x78, 0xB5, 0x56, 0x1B, 0x03, 0xCD, 0x70, 0xDA, 0x32, 0x60, 0x66, 0xB8, 0xA0, 0xCF), transport: [0, 0], raw_content: Bytes::copy_from_slice(&decode("24F3214D").unwrap()), content: PacketContent::Ack(Ack { @@ -53,7 +51,7 @@ mod tests { fn display() { let ack = Ack { checksum: 0x24F3214D }; println!("{}", ack); - assert!(format!("{}", ack) == "Checksum: 24f3214d"); + assert_eq!(format!("{}", ack), "Checksum: 24f3214d"); } } \ No newline at end of file -- cgit v1.2.3