Add Apophis special role

This commit is contained in:
NicolasCantu 2025-03-13 14:28:08 +01:00
parent 6f786c5cc9
commit 4d9b03ff18

View File

@ -25,13 +25,15 @@ pub const MAX_PRD_PAYLOAD_SIZE: usize = u16::MAX as usize; // 64KiB sounds reaso
#[derive(Debug, PartialEq, Eq)] #[derive(Debug, PartialEq, Eq)]
pub enum SpecialRoles { 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 { impl std::fmt::Display for SpecialRoles {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
let role_str = match self { let role_str = match self {
SpecialRoles::DEMIURGE => "demiurge", SpecialRoles::DEMIURGE => "demiurge",
SpecialRoles::APOPHIS => "apophis",
}; };
write!(f, "{}", role_str) write!(f, "{}", role_str)
} }
@ -43,6 +45,7 @@ impl FromStr for SpecialRoles {
fn from_str(s: &str) -> Result<Self, Self::Err> { fn from_str(s: &str) -> Result<Self, Self::Err> {
match s { match s {
"demiurge" => Ok(SpecialRoles::DEMIURGE), "demiurge" => Ok(SpecialRoles::DEMIURGE),
"apophis" => Ok(SpecialRoles::APOPHIS),
_ => Err(format!("Invalid role: {}", s)), _ => Err(format!("Invalid role: {}", s)),
} }
} }