summaryrefslogtreecommitdiff
path: root/src/protocol/udp.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/protocol/udp.rs')
-rw-r--r--src/protocol/udp.rs6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/protocol/udp.rs b/src/protocol/udp.rs
index c5fab65..d5302eb 100644
--- a/src/protocol/udp.rs
+++ b/src/protocol/udp.rs
@@ -1,3 +1,4 @@
+use crate::protocol::codec::Decode;
use nom::number;
use nom::IResult;
@@ -31,8 +32,8 @@ pub struct UdpHeader {
* API
******************************************************************************/
-impl UdpHeader {
- pub fn decode(input: &[u8]) -> IResult<&[u8], UdpHeader> {
+impl Decode<UdpHeader> for UdpHeader {
+ fn decode(input: &[u8]) -> IResult<&[u8], UdpHeader> {
let (input, source_port) = number::streaming::be_u16(input)?;
let (input, dest_port) = number::streaming::be_u16(input)?;
let (input, length) = number::streaming::be_u16(input)?;
@@ -57,6 +58,7 @@ impl UdpHeader {
#[cfg(test)]
mod tests {
use super::UdpHeader;
+ use crate::protocol::codec::Decode;
const LAST_SLICE: &'static [u8] = &[0xff];