etherparse/net/
arp_operation.rs

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