generate a module trait and call it
This commit is contained in:
14
src/lib.rs
14
src/lib.rs
@@ -7,17 +7,21 @@ pub mod test {
|
||||
value_errors: Vec<::memory::GuestValueError>,
|
||||
}
|
||||
|
||||
impl foo::Foo for WasiCtx {
|
||||
fn bar(&mut self, an_int: u32, an_float: f32) -> Result<(), types::Errno> {
|
||||
println!("BAR: {} {}", an_int, an_float);
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
// Errno is used as a first return value in the functions above, therefore
|
||||
// it must implement GuestError with type Context = WasiCtx.
|
||||
// The context type should let you do logging or debugging or whatever you need
|
||||
// with these errors. We just push them to vecs.
|
||||
impl ::memory::GuestError for types::Errno {
|
||||
type Context = WasiCtx;
|
||||
fn is_success(&self) -> bool {
|
||||
match self {
|
||||
types::Errno::Ok => true,
|
||||
_ => false,
|
||||
}
|
||||
fn success() -> types::Errno {
|
||||
types::Errno::Ok
|
||||
}
|
||||
fn from_memory_error(e: ::memory::MemoryError, ctx: &mut WasiCtx) -> types::Errno {
|
||||
ctx.mem_errors.push(e);
|
||||
|
||||
Reference in New Issue
Block a user