Nothing to see here, move along
at main 66 lines 1.3 kB view raw
1pub use lancer_core::types::*; 2 3#[derive(Debug, PartialEq, Eq)] 4pub struct BlockedPid { 5 pid: Pid, 6 generation: Generation, 7} 8 9impl BlockedPid { 10 pub(crate) fn from_blocked(pid: Pid, generation: Generation) -> Self { 11 Self { pid, generation } 12 } 13 14 #[cfg(lancer_test)] 15 pub(crate) unsafe fn trust(pid: Pid) -> Self { 16 Self { 17 pid, 18 generation: Generation::new(0), 19 } 20 } 21 22 pub const fn pid(&self) -> Pid { 23 self.pid 24 } 25 26 #[allow(dead_code)] 27 pub const fn generation(&self) -> Generation { 28 self.generation 29 } 30} 31 32#[derive(Debug, Clone, Copy, PartialEq, Eq)] 33pub struct NotificationBit(u8); 34 35impl NotificationBit { 36 #[allow(dead_code)] 37 pub const ZERO: Self = Self(0); 38 39 pub fn new(bit: u8) -> Option<Self> { 40 if bit < 64 { Some(Self(bit)) } else { None } 41 } 42 43 pub const fn mask(self) -> u64 { 44 1u64 << self.0 45 } 46} 47 48impl core::fmt::Display for NotificationBit { 49 fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { 50 write!(f, "{}", self.0) 51 } 52} 53 54#[derive(Debug, Clone, Copy, PartialEq, Eq)] 55#[repr(transparent)] 56pub struct CreatedPid(Pid); 57 58impl CreatedPid { 59 pub(crate) fn trust(pid: Pid) -> Self { 60 Self(pid) 61 } 62 63 pub const fn pid(self) -> Pid { 64 self.0 65 } 66}