• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /// Operation field value in an ARP packet.
2 #[derive(Clone, Copy, Debug, PartialEq, Eq, Ord, PartialOrd, Hash)]
3 pub struct ArpOperation(pub u16);
4 
5 impl ArpOperation {
6     pub const REQUEST: ArpOperation = ArpOperation(1);
7     pub const REPLY: ArpOperation = ArpOperation(2);
8 }
9 
10 impl From<u16> for ArpOperation {
11     #[inline]
from(raw: u16) -> Self12     fn from(raw: u16) -> Self {
13         ArpOperation(raw)
14     }
15 }
16 
17 #[cfg(test)]
18 mod tests {
19     use crate::ArpOperation;
20 
21     #[test]
from_u16()22     pub fn from_u16() {
23         assert_eq!(ArpOperation::from(12), ArpOperation(12))
24     }
25 }
26