pub trait DecodeCandid {
// Required method
fn decode_candid<T>(self) -> Result<T, String>
where T: CandidType + for<'de> Deserialize<'de>;
}Expand description
Extension trait for decoding Candid responses from inter-canister calls.
This trait provides a convenient method to decode the response of an inter-canister call into a Rust type, combining error handling for both call failures and decoding failures.
Required Methods§
Sourcefn decode_candid<T>(self) -> Result<T, String>where
T: CandidType + for<'de> Deserialize<'de>,
fn decode_candid<T>(self) -> Result<T, String>where
T: CandidType + for<'de> Deserialize<'de>,
Decodes the response as a Candid type.
This method handles both the call result and Candid decoding in a single step, converting any errors into descriptive string messages.
§Type Parameters
T- The type to decode the response into. Must implementCandidTypeandDeserialize.
§Returns
Ok(T)- The successfully decoded response.Err(String)- An error message describing either the call failure or decoding failure.
§Examples
let result: u32 = Call::bounded_wait(canister_id, "get_value")
.await
.decode_candid()?;Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.