1use core::ops::{BitOr, BitOrAssign};
4
5#[derive(Clone, Copy, Debug, Eq, PartialEq)]
7#[repr(transparent)]
8pub struct TcpFlags(u8);
9impl TcpFlags {
10 pub const FIN: Self = Self(1);
12 pub const SYN: Self = Self(2);
14 pub const RST: Self = Self(4);
16 pub const PSH: Self = Self(8);
18 pub const ACK: Self = Self(16);
20 pub const URG: Self = Self(32);
22 pub const ECE: Self = Self(64);
24 pub const CWR: Self = Self(128);
26 pub const fn new(raw: u8) -> Self {
28 Self(raw)
29 }
30 pub const fn raw(self) -> u8 {
32 self.0
33 }
34 pub const fn contains(self, other: Self) -> bool {
36 self.0 & other.0 == other.0
37 }
38 pub const fn union(self, other: Self) -> Self {
40 Self(self.0 | other.0)
41 }
42}
43impl BitOr for TcpFlags {
44 type Output = Self;
45 fn bitor(self, rhs: Self) -> Self {
46 self.union(rhs)
47 }
48}
49impl BitOrAssign for TcpFlags {
50 fn bitor_assign(&mut self, rhs: Self) {
51 *self = self.union(rhs);
52 }
53}