canic_core/ops/request/
mod.rs

1//! Helpers that build requests routed through the root canister.
2//!
3//! Non-root canisters submit orchestration requests to root using the
4//! `canic_response` endpoint. This module owns the request envelope and
5//! high-level helpers for creating new canisters, triggering upgrades, or
6//! moving cycles between principals.
7
8mod request;
9mod response;
10
11pub use request::*;
12pub use response::*;
13
14use crate::{Error, ThisError, ids::CanisterRole, ops::OpsError, types::Principal};
15
16///
17/// RequestOpsError
18/// Errors produced during request dispatch or response handling
19///
20
21#[derive(Debug, ThisError)]
22pub enum RequestOpsError {
23    #[error("canister type {0} not found")]
24    CanisterRoleNotFound(CanisterRole),
25
26    #[error("child canister {0} not found")]
27    ChildNotFound(Principal),
28
29    #[error("canister {0} is not a child of caller {1}")]
30    NotChildOfCaller(Principal, Principal),
31
32    #[error("canister {0}'s parent was not found")]
33    ParentNotFound(Principal),
34
35    #[error("invalid response type")]
36    InvalidResponseType,
37
38    #[error("cannot find the root canister")]
39    RootNotFound,
40}
41
42impl From<RequestOpsError> for Error {
43    fn from(err: RequestOpsError) -> Self {
44        OpsError::from(err).into()
45    }
46}