pub struct ManualReply<T: ?Sized>(/* private fields */);Expand description
Helper for replying or rejecting calls marked with manual_reply = true.
This struct mirrors the now-deprecated ManualReply<T> type from the
IC Rust CDK. It uses PhantomData<T> internally to preserve the correct
return type in the generated Candid interface, but never actually serializes
anything because you send the reply or reject manually.
§When to use
- Your method is annotated with
#[update(..., manual_reply = true)]or#[query(..., manual_reply = true)]. - You want to send the reply or reject explicitly, rather than having the CDK serialize and return your function’s result automatically.
- You still want the generated
.didfile to correctly show the return type.
§Example
#[update(manual_reply = true)]
fn my_method() -> ManualReply<()> {
if something_went_wrong() {
return ManualReply::reject("bad input");
}
ManualReply::one(())
}Implementations§
Source§impl<T: ?Sized> ManualReply<T>
impl<T: ?Sized> ManualReply<T>
Sourcepub fn one<U>(value: U) -> Selfwhere
U: CandidType,
pub fn one<U>(value: U) -> Selfwhere
U: CandidType,
Sends a reply containing the given value as a single Candid return.
§Example
ManualReply::one(42u64); // replies with 42Trait Implementations§
Source§impl<T> CandidType for ManualReply<T>where
T: CandidType + ?Sized,
impl<T> CandidType for ManualReply<T>where
T: CandidType + ?Sized,
Source§impl<T: Clone + ?Sized> Clone for ManualReply<T>
impl<T: Clone + ?Sized> Clone for ManualReply<T>
Source§fn clone(&self) -> ManualReply<T>
fn clone(&self) -> ManualReply<T>
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl<T: Default + ?Sized> Default for ManualReply<T>
impl<T: Default + ?Sized> Default for ManualReply<T>
Source§fn default() -> ManualReply<T>
fn default() -> ManualReply<T>
Returns the “default value” for a type. Read more
impl<T: Copy + ?Sized> Copy for ManualReply<T>
Auto Trait Implementations§
impl<T> Freeze for ManualReply<T>where
T: ?Sized,
impl<T> RefUnwindSafe for ManualReply<T>where
T: RefUnwindSafe + ?Sized,
impl<T> Send for ManualReply<T>
impl<T> Sync for ManualReply<T>
impl<T> Unpin for ManualReply<T>
impl<T> UnwindSafe for ManualReply<T>where
T: UnwindSafe + ?Sized,
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more