add serde de/ser impls for error

Signed-off-by: Jason Volk <jason@zemos.net>
This commit is contained in:
Jason Volk 2024-08-04 08:43:53 +00:00
parent bac795de5f
commit efa70b9e78
2 changed files with 18 additions and 0 deletions

13
src/core/error/serde.rs Normal file
View file

@ -0,0 +1,13 @@
use std::fmt::Display;
use serde::{de, ser};
use crate::Error;
impl de::Error for Error {
fn custom<T: Display + ToString>(msg: T) -> Self { Self::SerdeDe(msg.to_string().into()) }
}
impl ser::Error for Error {
fn custom<T: Display + ToString>(msg: T) -> Self { Self::SerdeSer(msg.to_string().into()) }
}