Trait ic_kit::Context[][src]

pub trait Context {
Show 20 methods fn trap(&self, message: &str) -> !;
fn print<S: AsRef<str>>(&self, s: S);
fn id(&self) -> Principal;
fn time(&self) -> u64;
fn balance(&self) -> u64;
fn caller(&self) -> Principal;
fn msg_cycles_available(&self) -> u64;
fn msg_cycles_accept(&self, amount: u64) -> u64;
fn msg_cycles_refunded(&self) -> u64;
fn store<T: 'static + Default>(&self, data: T);
fn get_mut<T: 'static + Default>(&self) -> &mut T;
fn delete<T: 'static + Default>(&self) -> bool;
fn stable_store<T>(&self, data: T) -> Result<(), Error>
    where
        T: ArgumentEncoder
;
fn stable_restore<T>(&self) -> Result<T, String>
    where
        T: for<'de> ArgumentDecoder<'de>
;
fn call_raw(
        &'static self,
        id: Principal,
        method: &'static str,
        args_raw: Vec<u8>,
        cycles: u64
    ) -> CallResponse<Vec<u8>>;
fn set_certified_data(&self, data: &[u8]);
fn data_certificate(&self) -> Option<Vec<u8>>; fn get<T: 'static + Default>(&self) -> &T { ... }
fn call<T: ArgumentEncoder, R: for<'a> ArgumentDecoder<'a>>(
        &'static self,
        id: Principal,
        method: &'static str,
        args: T
    ) -> CallResponse<R> { ... }
fn call_with_payment<T: ArgumentEncoder, R: for<'a> ArgumentDecoder<'a>>(
        &'static self,
        id: Principal,
        method: &'static str,
        args: T,
        cycles: u64
    ) -> CallResponse<R> { ... }
}

Required methods

Trap the code.

Print a message.

ID of the current canister.

The time in nanoseconds.

The balance of the canister.

The caller who has invoked this method on the canister.

Return the number of available cycles that is sent by the caller.

Accept the given amount of cycles, returns the actual amount of accepted cycles.

Return the cycles that were sent back by the canister that was just called. This method should only be called right after an inter-canister call.

Store the given data to the storage.

Return a mutable reference to the given data type, if the data is not present the default value of the type is constructed and stored. The changes made to the data during updates is preserved.

Remove the data associated with the given data type.

Store the given data to the stable storage.

Restore the data from the stable storage. If the data is not already stored the None value is returned.

Perform a call.

Set the certified data of the canister, this method traps if data.len > 32.

Returns the data certificate authenticating certified_data set by this canister.

Provided methods

Return the data associated with the given type. If the data is not present the default value of the type is returned.

Perform the call and return the response.

Implementors