Add Apophis special role

This commit is contained in:
NicolasCantu 2025-03-13 14:28:08 +01:00 committed by Nicolas Cantu
parent 174d52c8a9
commit dc55810e44

View File

@ -25,13 +25,15 @@ pub const MAX_PRD_PAYLOAD_SIZE: usize = u16::MAX as usize; // 64KiB sounds reaso
#[derive(Debug, PartialEq, Eq)]
pub enum SpecialRoles {
DEMIURGE,
DEMIURGE, // Only valid for the first state of a process
APOPHIS, // Users in this role have the power to destroy the process
}
impl std::fmt::Display for SpecialRoles {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
let role_str = match self {
SpecialRoles::DEMIURGE => "demiurge",
SpecialRoles::APOPHIS => "apophis",
};
write!(f, "{}", role_str)
}
@ -43,6 +45,7 @@ impl FromStr for SpecialRoles {
fn from_str(s: &str) -> Result<Self, Self::Err> {
match s {
"demiurge" => Ok(SpecialRoles::DEMIURGE),
"apophis" => Ok(SpecialRoles::APOPHIS),
_ => Err(format!("Invalid role: {}", s)),
}
}