liminal-server 0.25.4

Standalone server for the liminal messaging bus
Documentation
//! The permission class a data route declares.

use super::{GrantMode, HotAction};
use serde::{Deserialize, Serialize};

/// Single-valued permission class declared by a data route.
#[derive(Clone, Copy, Debug, PartialEq, Eq, Serialize, Deserialize)]
#[serde(tag = "class", rename_all = "snake_case")]
pub enum AccessRouteClass {
    /// Offline publication.
    Publish,
    /// Offline subscription.
    Subscribe,
    /// Offline service call.
    Call,
    /// Offline service serving.
    Serve,
    /// A live-only act with the schema's declared approval mode.
    Deliberate {
        /// Mode declared for this route; the live grant determines the outcome.
        mode: GrantMode,
    },
}

impl AccessRouteClass {
    /// Returns an offline action only for an explicitly hot route.
    #[must_use]
    pub const fn hot_action(self) -> Option<HotAction> {
        match self {
            Self::Publish => Some(HotAction::Publish),
            Self::Subscribe => Some(HotAction::Subscribe),
            Self::Call => Some(HotAction::Call),
            Self::Serve => Some(HotAction::Serve),
            Self::Deliberate { .. } => None,
        }
    }
}