pub struct EnvOps;Expand description
EnvOps
NOTE:
try_*getters are test-only helpers for incomplete env setup.- Non-
try_*getters assume the environment has been fully initialized during canister startup and will return errors if called earlier. - After initialization, absence of environment fields is a programmer error.
Implementations§
Source§impl EnvOps
impl EnvOps
Sourcepub fn init_root(identity: SubnetIdentity) -> Result<(), Error>
pub fn init_root(identity: SubnetIdentity) -> Result<(), Error>
Initialize environment state for the root canister during init.
This must only be called from the IC init hook.
Sourcepub fn init(env: EnvView, role: CanisterRole) -> Result<(), Error>
pub fn init(env: EnvView, role: CanisterRole) -> Result<(), Error>
Initialize environment state for a non-root canister during init.
This function must only be called from the IC init hook.
pub fn import(env: EnvView) -> Result<(), Error>
pub fn set_prime_root_pid(pid: Principal)
pub fn set_subnet_role(role: SubnetRole)
pub fn set_subnet_pid(pid: Principal)
pub fn set_root_pid(pid: Principal)
pub fn set_canister_role(role: CanisterRole)
pub fn is_prime_root() -> bool
pub fn is_prime_subnet() -> bool
pub fn is_root() -> bool
pub fn subnet_role() -> Result<SubnetRole, Error>
pub fn canister_role() -> Result<CanisterRole, Error>
pub fn subnet_pid() -> Result<Principal, Error>
pub fn root_pid() -> Result<Principal, Error>
pub fn prime_root_pid() -> Result<Principal, Error>
pub fn parent_pid() -> Result<Principal, Error>
Sourcepub fn require_root() -> Result<(), Error>
pub fn require_root() -> Result<(), Error>
Ensure the caller is the root canister.
Sourcepub fn restore_root() -> Result<(), Error>
pub fn restore_root() -> Result<(), Error>
Restore root environment context after upgrade.
Root identity and subnet metadata must already be present.
Sourcepub fn restore_role(role: CanisterRole) -> Result<(), Error>
pub fn restore_role(role: CanisterRole) -> Result<(), Error>
Restore canister role context after upgrade.
Environment data is expected to already exist in stable memory. Failure indicates a programmer error or corrupted state.
Auto Trait Implementations§
impl Freeze for EnvOps
impl RefUnwindSafe for EnvOps
impl Send for EnvOps
impl Sync for EnvOps
impl Unpin for EnvOps
impl UnwindSafe for EnvOps
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more