Skip to main content

liminal_server/auth_lys/
route_class.rs

1//! The permission class a data route declares.
2
3use super::{GrantMode, HotAction};
4use serde::{Deserialize, Serialize};
5
6/// Single-valued permission class declared by a data route.
7#[derive(Clone, Copy, Debug, PartialEq, Eq, Serialize, Deserialize)]
8#[serde(tag = "class", rename_all = "snake_case")]
9pub enum AccessRouteClass {
10    /// Offline publication.
11    Publish,
12    /// Offline subscription.
13    Subscribe,
14    /// Offline service call.
15    Call,
16    /// Offline service serving.
17    Serve,
18    /// A live-only act with the schema's declared approval mode.
19    Deliberate {
20        /// Mode declared for this route; the live grant determines the outcome.
21        mode: GrantMode,
22    },
23}
24
25impl AccessRouteClass {
26    /// Returns an offline action only for an explicitly hot route.
27    #[must_use]
28    pub const fn hot_action(self) -> Option<HotAction> {
29        match self {
30            Self::Publish => Some(HotAction::Publish),
31            Self::Subscribe => Some(HotAction::Subscribe),
32            Self::Call => Some(HotAction::Call),
33            Self::Serve => Some(HotAction::Serve),
34            Self::Deliberate { .. } => None,
35        }
36    }
37}