#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
#[repr(u8)]
pub enum ReactivityClass {
Static = 0,
PropsStable = 1,
Reactive = 2,
Unstable = 3,
}
impl ReactivityClass {
#[must_use]
pub const fn as_str(self) -> &'static str {
match self {
Self::Static => "static",
Self::PropsStable => "props-stable",
Self::Reactive => "reactive",
Self::Unstable => "unstable",
}
}
#[must_use]
pub const fn from_str(value: &str) -> Option<Self> {
match value.as_bytes() {
b"static" => Some(Self::Static),
b"props-stable" => Some(Self::PropsStable),
b"reactive" => Some(Self::Reactive),
b"unstable" => Some(Self::Unstable),
_ => None,
}
}
#[must_use]
pub const fn join(self, other: Self) -> Self {
if self.rank() >= other.rank() {
self
} else {
other
}
}
const fn rank(self) -> u8 {
self as u8
}
}