summaryrefslogtreecommitdiff
path: root/src/protocol/codec.rs
diff options
context:
space:
mode:
authorluwenpeng <[email protected]>2023-09-27 17:54:40 +0800
committerluwenpeng <[email protected]>2023-09-27 17:54:50 +0800
commite0c7dfa5bd9d424249b87ec07d377e94d49d139a (patch)
tree1d9bab0ed3b366ce3ff9ef0d9190162546521e7f /src/protocol/codec.rs
parent521fbe5464652d509e3290fd336c87ba28fa24c0 (diff)
[optimize] Packet Decode
1. Add a macro to obtain Packet’s encapsulation information (the returned data is an immutable reference to Packet) * get_innermost_special_encapsulation!() * get_outermost_special_encapsulation!() Example: let icmp_encapsulation : Option<&Encapsulation> = get_innermost_special_encapsulation!(&Packet, ICMP); Example: let l4_encapsulation : Option<&Encapsulation> = get_innermost_special_encapsulation!(&Packet, TCP | UDP); 2. Clean up the Clone/Copy Trait of PacketDecode to avoid memory copies caused by improper use by users.
Diffstat (limited to 'src/protocol/codec.rs')
-rw-r--r--src/protocol/codec.rs2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/protocol/codec.rs b/src/protocol/codec.rs
index 7bf2243..575e49d 100644
--- a/src/protocol/codec.rs
+++ b/src/protocol/codec.rs
@@ -2,7 +2,7 @@ use nom::IResult;
use std::fmt::Debug;
pub trait Decode {
- type Iterm: Debug;
+ type Iterm: Debug + PartialEq;
fn decode(input: &[u8]) -> IResult<&[u8], Self::Iterm>;
}