From e070270c3f1f10d46281ed7751ff95e15092e7f4 Mon Sep 17 00:00:00 2001 From: Nadrieril Date: Sun, 10 May 2020 22:09:43 +0100 Subject: Implement serialization --- serde_dhall/src/error.rs | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'serde_dhall/src/error.rs') diff --git a/serde_dhall/src/error.rs b/serde_dhall/src/error.rs index 896e8b9..3309fe4 100644 --- a/serde_dhall/src/error.rs +++ b/serde_dhall/src/error.rs @@ -11,6 +11,7 @@ pub struct Error(pub(crate) ErrorKind); pub(crate) enum ErrorKind { Dhall(DhallError), Deserialize(String), + Serialize(String), } impl From for Error { @@ -24,6 +25,7 @@ impl std::fmt::Display for Error { match &self.0 { ErrorKind::Dhall(err) => write!(f, "{}", err), ErrorKind::Deserialize(err) => write!(f, "{}", err), + ErrorKind::Serialize(err) => write!(f, "{}", err), } } } @@ -38,3 +40,12 @@ impl serde::de::Error for Error { ErrorKind::Deserialize(msg.to_string()).into() } } + +impl serde::ser::Error for Error { + fn custom(msg: T) -> Self + where + T: std::fmt::Display, + { + ErrorKind::Serialize(msg.to_string()).into() + } +} -- cgit v1.2.3