ic_dbms_api/
init.rs

1use candid::CandidType;
2use serde::{Deserialize, Serialize};
3
4/// Arguments for initializing or updating an IC DBMS canister.
5#[derive(Debug, CandidType, Serialize, Deserialize)]
6pub enum IcDbmsCanisterArgs {
7    Init(IcDbmsCanisterInitArgs),
8    Upgrade(IcDbmsCanisterUpgradeArgs),
9}
10
11impl IcDbmsCanisterArgs {
12    /// Unwraps the arguments as [`IcDbmsCanisterInitArgs`], or traps if it's not of that variant.
13    pub fn unwrap_init(self) -> IcDbmsCanisterInitArgs {
14        match self {
15            IcDbmsCanisterArgs::Init(args) => args,
16            _ => ic_cdk::trap("Expected IcDbmsCanisterArgs::Init"),
17        }
18    }
19
20    /// Unwraps the arguments as [`IcDbmsCanisterUpgradeArgs`], or traps if it's not of that variant.
21    pub fn unwrap_update(self) -> IcDbmsCanisterUpgradeArgs {
22        match self {
23            IcDbmsCanisterArgs::Upgrade(args) => args,
24            _ => ic_cdk::trap("Expected IcDbmsCanisterArgs::Upgrade"),
25        }
26    }
27}
28
29#[derive(Debug, CandidType, Serialize, Deserialize)]
30pub struct IcDbmsCanisterInitArgs {
31    pub allowed_principals: Vec<candid::Principal>,
32}
33
34#[derive(Debug, CandidType, Serialize, Deserialize)]
35pub struct IcDbmsCanisterUpgradeArgs;