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/multipart.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/multipart.rs')
| -rw-r--r-- | src/multipart.rs | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/src/multipart.rs b/src/multipart.rs index c68b442..ced4aaa 100644 --- a/src/multipart.rs +++ b/src/multipart.rs @@ -1,9 +1,7 @@ -use std::fmt::{Debug, Display}; + use bytes::Bytes; -use structdiff::{Difference, StructDiff}; -#[derive(PartialEq, Debug, Clone, Difference)] -#[difference(expose)] +#[derive(PartialEq, Debug, Clone)] pub struct MultiPart { payload: Bytes } @@ -14,16 +12,18 @@ impl From<Bytes> for MultiPart { } } -impl Display for MultiPart { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { +impl core::fmt::Display for MultiPart { + fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { f.write_fmt(format_args!("Multipart isn't defined.")) } } +// Tests for std operations #[cfg(test)] mod tests { - use std::str::FromStr; + use core::str::FromStr; use hex::decode; + use tinyvec::ArrayVec; use crate::{packet::*, packet_content::PacketContent}; use super::*; @@ -35,7 +35,7 @@ mod tests { let lhs_packet = Packet { route_type: RouteType::Direct, version: PayloadVersion::VersionOne, - path: vec![], + path: ArrayVec::new(), transport: [0, 0], raw_content: Bytes::copy_from_slice(&decode("13E8C59624").unwrap()), content: PacketContent::Multipart(MultiPart { @@ -47,6 +47,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), " Direct | v1 | | [] | | MULTIPART | Multipart isn't defined."); } }
\ No newline at end of file |
