pub struct Canister { /* private fields */ }Expand description
Can be used to represent a canister and different method on the canister.
Implementations
sourceimpl Canister
impl Canister
sourcepub fn new(id: Principal) -> Self
pub fn new(id: Principal) -> Self
Create a new canister with the given principal id, this handler rejects any call to a different canister id.
sourcepub fn context(&self) -> Ref<'_, MockContext>
pub fn context(&self) -> Ref<'_, MockContext>
Return a reference to the context associated with this canister.
sourcepub fn with_balance(self, cycles: u64) -> Self
pub fn with_balance(self, cycles: u64) -> Self
Update the balance of this canister.
sourcepub fn method<S: Into<String> + Copy>(
self,
name: S,
handler: Box<dyn CallHandler>
) -> Self
pub fn method<S: Into<String> + Copy>(
self,
name: S,
handler: Box<dyn CallHandler>
) -> Self
Add the given method to the canister.
Panics
If a method with the same name is already defined on the canister.
sourcepub fn or(self, handler: Box<dyn CallHandler>) -> Self
pub fn or(self, handler: Box<dyn CallHandler>) -> Self
Trait Implementations
Auto Trait Implementations
impl !RefUnwindSafe for Canister
impl !Send for Canister
impl !Sync for Canister
impl Unpin for Canister
impl !UnwindSafe for Canister
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