diff options
| author | Will Dillon <william@housedillon.com> | 2025-12-04 17:07:12 +0000 |
|---|---|---|
| committer | Will Dillon <william@housedillon.com> | 2025-12-04 17:07:12 +0000 |
| commit | bf21ebaaae44b267cfefc87eee9608c09aab96b7 (patch) | |
| tree | 67234092d3c85a9c58d1fa9ca51337ac480ebfb7 /src/ack.rs | |
| parent | Better than 90% everywhere. (diff) | |
| download | meshcore-rs-bf21ebaaae44b267cfefc87eee9608c09aab96b7.tar.gz meshcore-rs-bf21ebaaae44b267cfefc87eee9608c09aab96b7.zip | |
Getting closer to no-std being done
Diffstat (limited to 'src/ack.rs')
| -rw-r--r-- | src/ack.rs | 16 |
1 files changed, 7 insertions, 9 deletions
@@ -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<Bytes> 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 |
