wasmrs_codec/
error.rs

1#[derive(Debug)]
2pub enum Error {
3  MsgPackDecode(rmp_serde::decode::Error),
4  MsgPackEncode(rmp_serde::encode::Error),
5}
6
7#[cfg(feature = "std")]
8impl std::error::Error for Error {}
9
10impl core::fmt::Display for Error {
11  fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
12    match self {
13      Error::MsgPackDecode(e) => e.fmt(f),
14      Error::MsgPackEncode(e) => e.fmt(f),
15    }
16  }
17}
18
19impl From<Error> for wasmrs_frames::PayloadError {
20  fn from(val: Error) -> Self {
21    use core::fmt::Write;
22
23    let mut string: heapless::String<256> = heapless::String::new();
24    string.write_fmt(format_args!("{:.256}", val)).unwrap();
25
26    wasmrs_frames::PayloadError::new(0, string.as_str(), None)
27  }
28}