1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
//! 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,
}
}
}