1pub(crate) type Result<T> = core::result::Result<T, MemoryError>;
8
9#[derive(Debug, thiserror::Error)]
12pub enum MemoryError {
13 #[error(transparent)]
14 CoreError(#[from] eryon::Error),
15 #[cfg(feature = "serde")]
16 #[error(transparent)]
17 DeserializeError(#[from] serde::de::value::Error),
18 #[error(transparent)]
19 FmtError(#[from] core::fmt::Error),
20 #[cfg(feature = "std")]
21 #[error(transparent)]
22 IOError(#[from] std::io::Error),
23 #[cfg(feature = "serde_json")]
24 #[error(transparent)]
25 JsonError(#[from] serde_json::Error),
26}
27impl From<MemoryError> for eryon::Error {
29 fn from(err: MemoryError) -> Self {
30 match err {
31 MemoryError::CoreError(e) => e,
32 _ => eryon::Error::BoxError(Box::new(err)),
33 }
34 }
35}
36
37#[cfg(feature = "std")]
38impl From<&str> for MemoryError {
39 fn from(s: &str) -> Self {
40 eryon::Error::from(s).into()
41 }
42}
43
44#[cfg(feature = "std")]
45impl From<String> for MemoryError {
46 fn from(s: String) -> Self {
47 eryon::Error::from(s).into()
48 }
49}