diff options
| author | Kai Stevenson <kai@kaistevenson.com> | 2026-08-17 18:18:25 -0700 |
|---|---|---|
| committer | Kai Stevenson <kai@kaistevenson.com> | 2026-08-17 18:18:25 -0700 |
| commit | 54ae26e7c41f6c0a465a55c3cc5ee16ff81a1d70 (patch) | |
| tree | 40aa246f01cd9f66ba581528592ea0704e90164a /src/sim/cell/cell.rs | |
| parent | 3d476186f53d695c340c51dbd3aa14ff4621c520 (diff) | |
refactor/UX
Diffstat (limited to 'src/sim/cell/cell.rs')
| -rw-r--r-- | src/sim/cell/cell.rs | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/src/sim/cell/cell.rs b/src/sim/cell/cell.rs index 2664721..c4b0a8f 100644 --- a/src/sim/cell/cell.rs +++ b/src/sim/cell/cell.rs @@ -9,6 +9,7 @@ pub struct Cell { impl Cell { const FLAG_PARITY: u8 = 0b0000_0001; + const FLAG_RB: u8 = 0b0000_0010; #[inline] pub fn parity(self) -> u8 { @@ -20,8 +21,24 @@ impl Cell { } #[inline] pub fn match_parity(&mut self, seqno: u64) { - // TODO this will break with more flags - self.flags = (seqno as u8) & 0b1; + let parity = seqno % 2 != 0; + if parity { + self.flags |= Self::FLAG_PARITY; + } else { + self.flags = self.flags & !Self::FLAG_PARITY + } + } + + #[inline] + pub fn rb(self) -> bool { + self.flags & Self::FLAG_RB == 1 + } + pub fn set_rb(&mut self, rb: bool) { + if rb { + self.flags |= Self::FLAG_RB + } else { + self.flags = self.flags & !Self::FLAG_RB + } } } |
