1// SPDX-License-Identifier: Apache-2.0
2
3use alloc::string::{String, ToString};
4
5/// The error when serializing to/from a `Value`
6#[derive(Debug)]
7pub enum Error {
8 /// A custom error string produced by serde
9 Custom(String),
10}
11
12impl core::fmt::Display for Error {
13 fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
14 write!(f, "{:?}", self)
15 }
16}
17
18impl serde::de::StdError for Error {}
19
20impl serde::de::Error for Error {
21 #[inline]
22 fn custom<T: core::fmt::Display>(msg: T) -> Self {
23 Self::Custom(msg.to_string())
24 }
25}
26
27impl serde::ser::Error for Error {
28 #[inline]
29 fn custom<T: core::fmt::Display>(msg: T) -> Self {
30 Self::Custom(msg.to_string())
31 }
32}
33