canic_core/policy/pool/
mod.rs

1pub mod admissibility;
2pub mod authority;
3pub mod export;
4
5use crate::{Error, ThisError, policy::PolicyError};
6use candid::Principal;
7
8///
9/// PoolPolicyError
10/// All semantic denials related to pool policy.
11///
12/// These errors:
13/// - are side-effect free
14/// - are safe to bubble through ops/workflows
15/// - describe *why* an action is not permitted
16///
17
18#[derive(Clone, Debug, Eq, PartialEq, ThisError)]
19pub enum PoolPolicyError {
20    // Admissibility
21    #[error("pool entry blocked for {0}: canister is still registered in subnet registry")]
22    RegisteredInSubnet(Principal),
23
24    #[error("pool entry blocked for {pid}: local non-importable: {details}")]
25    NonImportableOnLocal { pid: Principal, details: String },
26
27    // Export
28    #[error("pool entry is not ready for export")]
29    NotReadyForExport,
30
31    #[error("pool entry is missing role metadata")]
32    MissingRole,
33
34    #[error("pool entry is missing module hash")]
35    MissingModuleHash,
36
37    // Authority
38    #[error("caller is not authorized to perform pool operation")]
39    NotAuthorized,
40}
41
42impl From<PoolPolicyError> for Error {
43    fn from(err: PoolPolicyError) -> Self {
44        PolicyError::from(err).into()
45    }
46}