Skip to main content

ManagementCanister

Struct ManagementCanister 

Source
pub struct ManagementCanister<'agent>(/* private fields */);
Expand description

The IC management canister.

Implementations§

Source§

impl<'agent> ManagementCanister<'agent>

Source

pub fn create(agent: &'agent Agent) -> Self

Create an instance of a ManagementCanister interface pointing to the specified Canister ID.

Source

pub fn from_canister(canister: Canister<'agent>) -> Self

Create a ManagementCanister interface from an existing canister object.

Source§

impl<'agent> ManagementCanister<'agent>

Source

pub fn canister_status( &self, canister_id: &Principal, ) -> impl 'agent + AsyncCall<Value = (CanisterStatusResult,)>

Get the status of a canister.

Source

pub fn create_canister<'canister>( &'canister self, ) -> CreateCanisterBuilder<'agent, 'canister>

Create a canister.

Source

pub fn deposit_cycles( &self, canister_id: &Principal, ) -> impl 'agent + AsyncCall<Value = ()>

This method deposits the cycles included in this call into the specified canister. Only the controller of the canister can deposit cycles.

Source

pub fn delete_canister( &self, canister_id: &Principal, ) -> impl 'agent + AsyncCall<Value = ()>

Deletes a canister.

Source

pub fn provisional_top_up_canister( &self, canister_id: &Principal, top_up_args: &ProvisionalTopUpCanisterArgs, ) -> impl 'agent + AsyncCall<Value = ()>

Until developers can convert real ICP tokens to a top up an existing canister, the system provides the provisional_top_up_canister method. It adds amount cycles to the balance of canister identified by amount (implicitly capping it at MAX_CANISTER_BALANCE).

Source

pub fn raw_rand(&self) -> impl 'agent + AsyncCall<Value = (Vec<u8>,)>

This method takes no input and returns 32 pseudo-random bytes to the caller. The return value is unknown to any part of the IC at time of the submission of this call. A new return value is generated for each call to this method.

Source

pub fn start_canister( &self, canister_id: &Principal, ) -> impl 'agent + AsyncCall<Value = ()>

Starts a canister.

Source

pub fn stop_canister( &self, canister_id: &Principal, ) -> impl 'agent + AsyncCall<Value = ()>

Stop a canister.

Source

pub fn uninstall_code( &self, canister_id: &Principal, ) -> impl 'agent + AsyncCall<Value = ()>

This method removes a canister’s code and state, making the canister empty again. Only the controller of the canister can uninstall code. Uninstalling a canister’s code will reject all calls that the canister has not yet responded to, and drop the canister’s code and state. Outstanding responses to the canister will not be processed, even if they arrive after code has been installed again. The canister is now empty. In particular, any incoming or queued calls will be rejected.

Source

pub fn install_code<'canister>( &'canister self, canister_id: &Principal, wasm: &'canister [u8], ) -> InstallCodeBuilder<'agent, 'canister>

Install a canister, with all the arguments necessary for creating the canister.

Source

pub fn update_settings<'canister>( &'canister self, canister_id: &Principal, ) -> UpdateSettingsBuilder<'agent, 'canister>

Update one or more of a canisters settings (i.e its controller, compute allocation, or memory allocation.)

Source

pub fn upload_chunk( &self, canister_id: &Principal, upload_chunk_args: &UploadChunkArgs, ) -> impl 'agent + AsyncCall<Value = (UploadChunkResult,)>

Upload a chunk of a WASM module to a canister’s chunked WASM storage.

Source

pub fn clear_chunk_store( &self, canister_id: &Principal, ) -> impl 'agent + AsyncCall<Value = ()>

Clear a canister’s chunked WASM storage.

Source

pub fn stored_chunks( &self, canister_id: &Principal, ) -> impl 'agent + AsyncCall<Value = (StoredChunksResult,)>

Get a list of the hashes of a canister’s stored WASM chunks

Source

pub fn install_chunked_code<'canister>( &'canister self, canister_id: &Principal, wasm_module_hash: &[u8], ) -> InstallChunkedCodeBuilder<'agent, 'canister>

Install a canister module previously uploaded in chunks via upload_chunk.

Source

pub fn install<'canister: 'builder, 'builder>( &'canister self, canister_id: &Principal, wasm: &'builder [u8], ) -> InstallBuilder<'agent, 'canister, 'builder>

Install a canister module, automatically selecting one-shot installation or chunked installation depending on module size.

§Warnings

This will clear chunked code storage if chunked installation is used. Do not use with canisters that you are manually uploading chunked code to.

Source

pub fn fetch_canister_logs( &self, args: &FetchCanisterLogsArgs, ) -> impl 'agent + SyncCall<Value = (FetchCanisterLogsResult,)>

Fetch (query) the logs of a canister.

Source

pub fn take_canister_snapshot( &self, take_args: &TakeCanisterSnapshotArgs, ) -> impl 'agent + AsyncCall<Value = (Snapshot,)>

Creates a canister snapshot, optionally replacing an existing snapshot.

Canisters should be stopped before running this method!
Source

pub fn load_canister_snapshot( &self, load_args: &LoadCanisterSnapshotArgs, ) -> impl 'agent + AsyncCall<Value = ()>

Loads a canister snapshot by ID, replacing the canister’s state with its state at the time the snapshot was taken.

Canisters should be stopped before running this method!
Source

pub fn list_canister_snapshots( &self, canister_id: &Principal, ) -> impl 'agent + AsyncCall<Value = (Vec<Snapshot>,)>

List a canister’s recorded snapshots.

Source

pub fn delete_canister_snapshot( &self, delete_args: &DeleteCanisterSnapshotArgs, ) -> impl 'agent + AsyncCall<Value = ()>

Deletes a recorded canister snapshot by ID.

Source

pub fn read_canister_snapshot_metadata( &self, metadata_args: &ReadCanisterSnapshotMetadataArgs, ) -> impl 'agent + AsyncCall<Value = (ReadCanisterSnapshotMetadataResult,)>

Reads the metadata of a recorded canister snapshot by canister ID and snapshot ID.

Source

pub fn read_canister_snapshot_data( &self, data_args: &ReadCanisterSnapshotDataArgs, ) -> impl 'agent + AsyncCall<Value = (ReadCanisterSnapshotDataResult,)>

Reads the data of a recorded canister snapshot by canister ID and snapshot ID.

Source

pub fn upload_canister_snapshot_metadata( &self, metadata_args: &UploadCanisterSnapshotMetadataArgs, ) -> impl 'agent + AsyncCall<Value = (UploadCanisterSnapshotMetadataResult,)>

Uploads the metadata of a canister snapshot by canister ID.

Source

pub fn upload_canister_snapshot_data( &self, data_args: &UploadCanisterSnapshotDataArgs, ) -> impl 'agent + AsyncCall<Value = ()>

Uploads the data of a canister snapshot by canister ID and snapshot ID..

Source

pub fn canister_metadata( &self, args: &CanisterMetadataArgs, ) -> impl 'agent + SyncCall<Value = (CanisterMetadataResult,)>

Fetch a named metadata section of a canister’s Wasm module.

Methods from Deref<Target = Canister<'agent>>§

Source

pub fn canister_id_(&self) -> &Principal

Get the canister ID of this canister. Prefer using canister_id instead.

Source

pub fn canister_id(&self) -> &Principal

Get the canister ID of this canister.

Source

pub fn update_<'canister>( &'canister self, method_name: &str, ) -> AsyncCallBuilder<'agent, 'canister>

Create an AsyncCallBuilder to do an update call. Prefer using update instead.

Source

pub fn update<'canister>( &'canister self, method_name: &str, ) -> AsyncCallBuilder<'agent, 'canister>

Create an AsyncCallBuilder to do an update call.

Source

pub fn query_<'canister>( &'canister self, method_name: &str, ) -> SyncCallBuilder<'agent, 'canister>

Create a SyncCallBuilder to do a query call. Prefer using query instead.

Source

pub fn query<'canister>( &'canister self, method_name: &str, ) -> SyncCallBuilder<'agent, 'canister>

Create a SyncCallBuilder to do a query call.

Source

pub async fn wait<'canister>( &'canister self, request_id: &RequestId, ) -> Result<Vec<u8>, AgentError>

Call request_status on the RequestId in a loop and return the response as a byte vector.

Source

pub fn clone_with_(&self, id: Principal) -> Self

Creates a copy of this canister, changing the canister ID to the provided principal. Prefer using clone_with instead.

Source

pub fn clone_with(&self, id: Principal) -> Self

Creates a copy of this canister, changing the canister ID to the provided principal.

Trait Implementations§

Source§

impl<'agent> Clone for ManagementCanister<'agent>

Source§

fn clone(&self) -> ManagementCanister<'agent>

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<'agent> Debug for ManagementCanister<'agent>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'agent> Deref for ManagementCanister<'agent>

Source§

type Target = Canister<'agent>

The resulting type after dereferencing.
Source§

fn deref(&self) -> &Self::Target

Dereferences the value.

Auto Trait Implementations§

§

impl<'agent> !RefUnwindSafe for ManagementCanister<'agent>

§

impl<'agent> !UnwindSafe for ManagementCanister<'agent>

§

impl<'agent> Freeze for ManagementCanister<'agent>

§

impl<'agent> Send for ManagementCanister<'agent>

§

impl<'agent> Sync for ManagementCanister<'agent>

§

impl<'agent> Unpin for ManagementCanister<'agent>

§

impl<'agent> UnsafeUnpin for ManagementCanister<'agent>

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

Source§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more