ic_backup/model/ic_request/method/mod.rs
1//! Closed method identities and semantic effect classes; no arbitrary method hook.
2
3use serde::{Deserialize, Serialize};
4
5/// Maintained closed IC management methods for the initial host-ingress codec.
6#[derive(Clone, Copy, Debug, Deserialize, Eq, PartialEq, Serialize)]
7#[serde(rename_all = "snake_case")]
8pub enum IcManagementMethodRecord {
9 /// Replicated lifecycle/controller/status observation.
10 CanisterStatus,
11 /// Replicated snapshot inventory observation, with distinct read permission.
12 ListCanisterSnapshots,
13 /// Load exact snapshot bytes into the same selected existing canister.
14 LoadCanisterSnapshot,
15 /// Start the selected existing canister; reviewed final state stays caller-owned.
16 StartCanister,
17 /// Stop the selected existing canister; application quiescence stays caller-owned.
18 StopCanister,
19 /// Create a new snapshot, retaining code and previously retained snapshots.
20 TakeCanisterSnapshot,
21}
22impl IcManagementMethodRecord {
23 /// Read the exact protocol method name, without aliases or arbitrary strings.
24 #[must_use]
25 pub const fn name(self) -> &'static str {
26 match self {
27 Self::CanisterStatus => "canister_status",
28 Self::ListCanisterSnapshots => "list_canister_snapshots",
29 Self::LoadCanisterSnapshot => "load_canister_snapshot",
30 Self::StartCanister => "start_canister",
31 Self::StopCanister => "stop_canister",
32 Self::TakeCanisterSnapshot => "take_canister_snapshot",
33 }
34 }
35 /// Classify state observation versus mutation; both use replicated update ingress.
36 #[must_use]
37 pub const fn effect(self) -> IcRequestEffect {
38 match self {
39 Self::CanisterStatus | Self::ListCanisterSnapshots => IcRequestEffect::Observation,
40 Self::LoadCanisterSnapshot
41 | Self::StartCanister
42 | Self::StopCanister
43 | Self::TakeCanisterSnapshot => IcRequestEffect::Mutation,
44 }
45 }
46}
47
48/// Semantic attempt class, distinct from transport update/query mode or authority.
49#[derive(Clone, Copy, Debug, Eq, PartialEq)]
50pub enum IcRequestEffect {
51 /// Reconciliation/state observation, still potentially paid and separately bounded.
52 Observation,
53 /// Exact snapshot or lifecycle mutation requiring its original attempt allowance.
54 Mutation,
55}