diff options
author | Nadrieril | 2020-05-10 22:09:43 +0100 |
---|---|---|
committer | Nadrieril | 2020-10-28 22:52:41 +0000 |
commit | e070270c3f1f10d46281ed7751ff95e15092e7f4 (patch) | |
tree | 46c22c75f209c5112030f3db6609ed64ff4888d3 /serde_dhall/src/error.rs | |
parent | 5f3ca811f09dcf6f09fb9b60fcd2664d06762f39 (diff) |
Implement serialization
Diffstat (limited to 'serde_dhall/src/error.rs')
-rw-r--r-- | serde_dhall/src/error.rs | 11 |
1 files changed, 11 insertions, 0 deletions
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<ErrorKind> 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<T>(msg: T) -> Self + where + T: std::fmt::Display, + { + ErrorKind::Serialize(msg.to_string()).into() + } +} |