1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
#[derive(Debug)] pub enum Error { InvalidReferent, Mac(crypto_mac::MacError), Signature(ed25519_dalek::SignatureError), Bincode(bincode::Error), Store(toboggan_kv::Error), TryFromSlice, Base64Error, } impl From<toboggan_kv::Error> for Error { fn from(e: toboggan_kv::Error) -> Self { Error::Store(e) } } impl From<crypto_mac::MacError> for Error { fn from(e: crypto_mac::MacError) -> Self { Error::Mac(e) } } impl From<ed25519_dalek::SignatureError> for Error { fn from(e: ed25519_dalek::SignatureError) -> Self { Error::Signature(e) } } impl From<bincode::Error> for Error { fn from(e: bincode::Error) -> Self { Self::Bincode(e) } } #[cfg(target_arch = "wasm32")] impl std::convert::Into<wasm_bindgen::JsValue> for Error { fn into(self) -> wasm_bindgen::JsValue { format!("{:?}", self).into() } } impl std::convert::From<Error> for std::io::Error { fn from(error: Error) -> Self { use std::io::ErrorKind; std::io::Error::new(ErrorKind::Other, format!("{:?}", error)) } }