Watcher

Struct Watcher 

Source
pub struct Watcher {
    pub called_id: bool,
    pub called_time: bool,
    pub called_balance: bool,
    pub called_caller: bool,
    pub called_msg_cycles_available: bool,
    pub called_msg_cycles_accept: bool,
    pub called_msg_cycles_refunded: bool,
    pub called_stable_store: bool,
    pub called_stable_restore: bool,
    pub called_set_certified_data: bool,
    pub called_data_certificate: bool,
    /* private fields */
}
Expand description

A watcher can be used to inspect the calls made in a call.

Fields§

§called_id: bool

True if the context.id() was called during execution.

§called_time: bool

True if the context.time() was called during execution.

§called_balance: bool

True if the context.balance() was called during execution.

§called_caller: bool

True if the context.caller() was called during execution.

§called_msg_cycles_available: bool

True if the context.msg_cycles_available() was called during execution.

§called_msg_cycles_accept: bool

True if the context.msg_cycles_accept() was called during execution.

§called_msg_cycles_refunded: bool

True if the context.msg_cycles_refunded() was called during execution.

§called_stable_store: bool

True if the context.stable_store() was called during execution.

§called_stable_restore: bool

True if the context.stable_restore() was called during execution.

§called_set_certified_data: bool

True if the context.set_certified_data() was called during execution.

§called_data_certificate: bool

True if the context.data_certificate() was called during execution.

Implementations§

Source§

impl Watcher

Source

pub fn record_call(&mut self, call: WatcherCall)

Push a call to the call history of the watcher.

Source

pub fn call_count(&self) -> usize

Return the number of calls made during the last execution.

Source

pub fn cycles_consumed(&self) -> u64

Returns the total amount of cycles consumed in inter-canister calls.

Source

pub fn cycles_refunded(&self) -> u64

Returns the total amount of cycles refunded in inter-canister calls.

Source

pub fn cycles_sent(&self) -> u64

Returns the total amount of cycles sent in inter-canister calls, not deducing the refunded amounts.

Source

pub fn get_call(&self, n: usize) -> &WatcherCall

Return the n-th call that took place during the execution.

Source

pub fn is_method_called(&self, method_name: &str) -> bool

Returns true if the given method was called during the execution.

Source

pub fn is_canister_called(&self, canister_id: &Principal) -> bool

Returns true if the given canister was called during the execution.

Source

pub fn is_called(&self, canister_id: &Principal, method_name: &str) -> bool

Returns true if the given method was called.

Source

pub fn is_modified<T: 'static>(&self) -> bool

Returns true if the given storage item was accessed in a mutable way during the execution. This method tracks calls to:

  • context.store()
  • context.get_mut()
  • context.delete()

Trait Implementations§

Source§

impl Default for Watcher

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

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.