wasm_embedded_spec/
lib.rs

1//! Embedded WASM Interface Specifications.
2//!
3//! This crate provides the WITX interface specification for embedded wasm platforms and HALs,
4//! with bindings generated using wiggle for rust, and bindgen for C.
5//!
6//! https://github.com/embedded-wasm/spec
7
8#![cfg_attr(not(feature = "std"), no_std)]
9
10pub mod api;
11
12pub mod gpio;
13pub mod i2c;
14pub mod spi;
15pub mod uart;
16
17/// Embedded WASM Error type
18///
19/// Note these values _must_ correspond to WASM/WITX spec
20#[derive(Clone, PartialEq, Debug)]
21pub enum Error {
22    InvalidArg,
23    Unexpected,
24    Failed,
25    NoDevice,
26    Unsupported,
27}
28
29#[cfg(feature="wiggle")]
30impl From<Error> for crate::api::types::Errno {
31    fn from(e: Error) -> crate::api::types::Errno {
32        use crate::api::types::Errno;
33
34        match e {
35            Error::InvalidArg => Errno::InvalidArg,
36            Error::Unexpected => Errno::Unexpected,
37            Error::Failed => Errno::Failed,
38            Error::NoDevice => Errno::NoDevice,
39            Error::Unsupported => Errno::Unsupported,
40        }
41
42    }
43}