shaum_types/
status.rs

1//! Fasting status enum (Hukum).
2
3use serde::{Serialize, Deserialize};
4use std::fmt;
5
6/// Fasting status (Hukum). Ordered by priority: Haram > Wajib > SunnahMuakkadah > Sunnah > Makruh > Mubah.
7#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, PartialOrd, Ord, Serialize, Deserialize)]
8pub enum FastingStatus {
9    Mubah,
10    Makruh,
11    Sunnah,
12    SunnahMuakkadah,
13    Wajib,
14    Haram,
15}
16
17impl FastingStatus {
18    #[inline] pub fn is_haram(&self) -> bool { matches!(self, Self::Haram) }
19    #[inline] pub fn is_wajib(&self) -> bool { matches!(self, Self::Wajib) }
20    #[inline] pub fn is_sunnah(&self) -> bool { matches!(self, Self::Sunnah | Self::SunnahMuakkadah) }
21    #[inline] pub fn is_makruh(&self) -> bool { matches!(self, Self::Makruh) }
22    #[inline] pub fn is_mubah(&self) -> bool { matches!(self, Self::Mubah) }
23}
24
25impl fmt::Display for FastingStatus {
26    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
27        let s = match self {
28            Self::Mubah => "Mubah (Permissible)",
29            Self::Makruh => "Makruh (Disliked)",
30            Self::Sunnah => "Sunnah (Recommended)",
31            Self::SunnahMuakkadah => "Sunnah Muakkadah (Highly Recommended)",
32            Self::Wajib => "Wajib (Obligatory)",
33            Self::Haram => "Haram (Forbidden)",
34        };
35        write!(f, "{}", s)
36    }
37}