Type Alias wasmtime::Result

source ·
pub type Result<T, E = Error> = Result<T, E>;
Expand description

A convenience wrapper for Result<T, anyhow::Error>.

This type can be used to interact with wasmtimes’s extensive use of anyhow::Error while still not directly depending on anyhow. This type alias is identical to anyhow::Result. Result<T, Error>

This is a reasonable return type to use throughout your application but also for fn main; if you do, failures will be printed along with any context and a backtrace if one was captured.

anyhow::Result may be used with one or two type parameters.

use anyhow::Result;

fn demo1() -> Result<T> {...}
           // ^ equivalent to std::result::Result<T, anyhow::Error>

fn demo2() -> Result<T, OtherError> {...}
           // ^ equivalent to std::result::Result<T, OtherError>

Example

use anyhow::Result;

fn main() -> Result<()> {
    let config = std::fs::read_to_string("cluster.json")?;
    let map: ClusterMap = serde_json::from_str(&config)?;
    println!("cluster info: {:#?}", map);
    Ok(())
}

Aliased Type§

enum Result<T, E = Error> {
    Ok(T),
    Err(E),
}

Variants§

§1.0.0

Ok(T)

Contains the success value

§1.0.0

Err(E)

Contains the error value

Trait Implementations§

source§

impl<T, E> ComponentType for Result<T, E>where T: ComponentType, E: ComponentType,

Available on crate feature component-model only.
source§

impl<T, E> Lift for Result<T, E>where T: Lift, E: Lift,

Available on crate feature component-model only.
source§

impl<T, E> Lower for Result<T, E>where T: Lower, E: Lower,

Available on crate feature component-model only.
source§

impl<T> WasmRet for Result<T>where T: WasmRet,