Trait holochain_types::prelude::CallbackResult
source · pub trait CallbackResult: Sized {
fn is_definitive(&self) -> bool;
fn try_from_wasm_error(wasm_error: WasmError) -> Result<Self, WasmError>;
}
Required Methods§
sourcefn is_definitive(&self) -> bool
fn is_definitive(&self) -> bool
if a callback result is definitive we should halt any further iterations over remaining calls e.g. over sparse names or subsequent zomes typically a clear failure is definitive but success and missing dependencies are not in the case of success or missing deps, a subsequent callback could give us a definitive answer like a fail, and we don’t want to over-optimise wasm calls and miss a clear failure
sourcefn try_from_wasm_error(wasm_error: WasmError) -> Result<Self, WasmError>
fn try_from_wasm_error(wasm_error: WasmError) -> Result<Self, WasmError>
when a WasmError is returned from a callback (e.g. via ?
operator) it might mean either:
- There was an error that prevented the callback from coming to a CallbackResult (e.g. failing to connect to database)
- There was an error that should be interpreted as a CallbackResult::Fail (e.g. data failed to deserialize)
Typically this can be split as host/wasm errors are the former, and serialization/guest errors the latter. This function allows each CallbackResult to explicitly map itself.