EnvOps

Struct EnvOps 

Source
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

Source

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.

Source

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.

Source

pub fn import(env: EnvView) -> Result<(), Error>

Source

pub fn set_prime_root_pid(pid: Principal)

Source

pub fn set_subnet_role(role: SubnetRole)

Source

pub fn set_subnet_pid(pid: Principal)

Source

pub fn set_root_pid(pid: Principal)

Source

pub fn set_canister_role(role: CanisterRole)

Source

pub fn is_prime_root() -> bool

Source

pub fn is_prime_subnet() -> bool

Source

pub fn is_root() -> bool

Source

pub fn subnet_role() -> Result<SubnetRole, Error>

Source

pub fn canister_role() -> Result<CanisterRole, Error>

Source

pub fn subnet_pid() -> Result<Principal, Error>

Source

pub fn root_pid() -> Result<Principal, Error>

Source

pub fn prime_root_pid() -> Result<Principal, Error>

Source

pub fn parent_pid() -> Result<Principal, Error>

Source

pub fn require_root() -> Result<(), Error>

Ensure the caller is the root canister.

Source

pub fn deny_root() -> Result<(), Error>

Ensure the caller is not the root canister.

Source

pub fn restore_root() -> Result<(), Error>

Restore root environment context after upgrade.

Root identity and subnet metadata must already be present.

Source

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.

Source

pub fn export() -> EnvView

Export a snapshot of the current environment metadata.

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V