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: boolTrue if the context.id() was called during execution.
called_time: boolTrue if the context.time() was called during execution.
called_balance: boolTrue if the context.balance() was called during execution.
called_caller: boolTrue if the context.caller() was called during execution.
called_msg_cycles_available: boolTrue if the context.msg_cycles_available() was called during execution.
called_msg_cycles_accept: boolTrue if the context.msg_cycles_accept() was called during execution.
called_msg_cycles_refunded: boolTrue if the context.msg_cycles_refunded() was called during execution.
called_stable_store: boolTrue if the context.stable_store() was called during execution.
called_stable_restore: boolTrue if the context.stable_restore() was called during execution.
called_set_certified_data: boolTrue if the context.set_certified_data() was called during execution.
called_data_certificate: boolTrue if the context.data_certificate() was called during execution.
Implementations
sourceimpl Watcher
impl Watcher
sourcepub fn record_call(&mut self, call: WatcherCall)
pub fn record_call(&mut self, call: WatcherCall)
Push a call to the call history of the watcher.
sourcepub fn call_count(&self) -> usize
pub fn call_count(&self) -> usize
Return the number of calls made during the last execution.
sourcepub fn cycles_consumed(&self) -> u64
pub fn cycles_consumed(&self) -> u64
Returns the total amount of cycles consumed in inter-canister calls.
sourcepub fn cycles_refunded(&self) -> u64
pub fn cycles_refunded(&self) -> u64
Returns the total amount of cycles refunded in inter-canister calls.
sourcepub fn cycles_sent(&self) -> u64
pub fn cycles_sent(&self) -> u64
Returns the total amount of cycles sent in inter-canister calls, not deducing the refunded amounts.
sourcepub fn get_call(&self, n: usize) -> &WatcherCall
pub fn get_call(&self, n: usize) -> &WatcherCall
Return the n-th call that took place during the execution.
sourcepub fn is_method_called(&self, method_name: &str) -> bool
pub fn is_method_called(&self, method_name: &str) -> bool
Returns true if the given method was called during the execution.
sourcepub fn is_canister_called(&self, canister_id: &Principal) -> bool
pub fn is_canister_called(&self, canister_id: &Principal) -> bool
Returns true if the given canister was called during the execution.
sourcepub fn is_called(&self, canister_id: &Principal, method_name: &str) -> bool
pub fn is_called(&self, canister_id: &Principal, method_name: &str) -> bool
Returns true if the given method was called.
sourcepub fn is_modified<T: 'static>(&self) -> bool
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
Auto Trait Implementations
impl RefUnwindSafe for Watcher
impl Send for Watcher
impl Sync for Watcher
impl Unpin for Watcher
impl UnwindSafe for Watcher
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more