game_toolkit_dosbus/
port.rs1#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
3pub struct PortRange {
4 start: u16,
5 end: u16,
6}
7
8impl PortRange {
9 pub const fn new(start: u16, end: u16) -> Self {
14 assert!(start <= end, "reversed I/O port range");
15 Self { start, end }
16 }
17
18 pub const fn single(port: u16) -> Self {
20 Self::new(port, port)
21 }
22
23 pub const fn start(self) -> u16 {
25 self.start
26 }
27
28 pub const fn end(self) -> u16 {
30 self.end
31 }
32
33 pub const fn contains(self, port: u16) -> bool {
35 self.start <= port && port <= self.end
36 }
37
38 pub const fn overlaps(self, other: Self) -> bool {
40 self.start <= other.end && other.start <= self.end
41 }
42}