wasm3_provider/errors.rs
1/// This crate's generic Error type
2#[derive(Debug, thiserror::Error)]
3pub enum Error {
4 /// Error returned from the wasm3 rust wrapper.
5 #[error("WASM3: {0}")]
6 Wasm3(String),
7}
8
9impl From<wasm3::error::Error> for Error {
10 fn from(e: wasm3::error::Error) -> Self {
11 Error::Wasm3(e.to_string())
12 }
13}
14
15// `wasm3`'s error type isn't Send or Sync since it contains a raw
16// pointer. This trait is to normalize `Result`'s coming from wasm3 into ones that
17// are easier to manage.
18pub(crate) trait SendSyncResult<T> {
19 fn to_wapc(self) -> Result<T, Error>;
20}
21
22impl<T> SendSyncResult<T> for Result<T, wasm3::error::Error> {
23 fn to_wapc(self) -> Result<T, Error> {
24 self.map_err(|e| e.into())
25 }
26}