1pub const REFLEX_STATUS_HEADER: &str = "X-Reflex-Status";
3pub const REFLEX_STATUS_HEALTHY: &str = "healthy";
5pub const REFLEX_STATUS_READY: &str = "ready";
7pub const REFLEX_STATUS_NOT_READY: &str = "not_ready";
9pub const REFLEX_STATUS_STORED: &str = "stored";
11pub const REFLEX_STATUS_ERROR: &str = "error";
13
14#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
15pub enum ReflexStatus {
17 HitL1Exact,
19 HitL2Semantic,
21 HitL3Verified,
23 Miss,
25}
26
27impl ReflexStatus {
28 #[inline]
29 pub fn as_header_value(&self) -> &'static str {
31 match self {
32 ReflexStatus::HitL1Exact => "HIT_L1_EXACT",
33 ReflexStatus::HitL2Semantic => "HIT_L2_SEMANTIC",
34 ReflexStatus::HitL3Verified => "HIT_L3_VERIFIED",
35 ReflexStatus::Miss => "MISS",
36 }
37 }
38
39 #[inline]
40 pub fn is_hit(&self) -> bool {
42 !matches!(self, ReflexStatus::Miss)
43 }
44}
45
46impl std::fmt::Display for ReflexStatus {
47 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
48 write!(f, "{}", self.as_header_value())
49 }
50}