summaryrefslogtreecommitdiff
path: root/crates
diff options
context:
space:
mode:
authorHenry Gressmann <mail@henrygressmann.de>2023-11-30 15:58:37 +0100
committerHenry Gressmann <mail@henrygressmann.de>2023-11-30 15:58:37 +0100
commit2d69fbb206ef620251f7cf6618131e6be226eca7 (patch)
tree286d5947eeeaef3bf4e52b27e994f18a362f1c38 /crates
parentd91678d58ba9672a54faec266d4f90da6bed932a (diff)
chore: remove unneeded dependencies
Signed-off-by: Henry Gressmann <mail@henrygressmann.de>
Diffstat (limited to 'crates')
-rw-r--r--crates/tinywasm/Cargo.toml6
-rw-r--r--crates/tinywasm/src/error.rs23
2 files changed, 19 insertions, 10 deletions
diff --git a/crates/tinywasm/Cargo.toml b/crates/tinywasm/Cargo.toml
index 807a19f..02ea1f5 100644
--- a/crates/tinywasm/Cargo.toml
+++ b/crates/tinywasm/Cargo.toml
@@ -7,11 +7,11 @@ edition="2021"
path="src/lib.rs"
[dependencies]
-thiserror={version="1.0", package="thiserror-core", default-features=false}
+# fork of wasmparser with no_std support, see https://github.com/bytecodealliance/wasmtime/issues/3495
+# TODO: create dependency free parser
wasmparser={version="0.100", package="wasmparser-nostd", default-features=false}
tracing={version="0.1.38", default-features=false} # logging
-hashbrown="0.14"
[features]
default=["std"]
-std=["thiserror/std"]
+std=[]
diff --git a/crates/tinywasm/src/error.rs b/crates/tinywasm/src/error.rs
index a253880..9b97a59 100644
--- a/crates/tinywasm/src/error.rs
+++ b/crates/tinywasm/src/error.rs
@@ -1,18 +1,27 @@
use alloc::string::{String, ToString};
-use thiserror::Error;
+use core::fmt::Display;
-#[derive(Debug, Error)]
+#[derive(Debug)]
pub enum Error {
- #[error("error parsing module")]
ParseError { message: String, offset: usize },
-
- #[error("unsupported feature: {0}")]
UnsupportedFeature(String),
-
- #[error("unknown error: {0}")]
Other(String),
}
+impl Display for Error {
+ fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
+ match self {
+ Self::ParseError { message, offset } => {
+ write!(f, "error parsing module: {} at offset {}", message, offset)
+ }
+ Self::UnsupportedFeature(feature) => write!(f, "unsupported feature: {}", feature),
+ Self::Other(message) => write!(f, "unknown error: {}", message),
+ }
+ }
+}
+
+impl crate::std::error::Error for Error {}
+
impl Error {
pub fn other<T>(message: &str) -> Result<T, Self> {
Err(Self::Other(message.to_string()))