pub struct Canister { /* private fields */ }Expand description
Can be used to represent a canister and different method on the canister.
Implementations§
Source§impl 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 !Freeze for Canister
impl !RefUnwindSafe for Canister
impl !Send for Canister
impl !Sync for Canister
impl Unpin for Canister
impl !UnwindSafe for Canister
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more