diff options
author | Nadrieril | 2020-04-05 11:43:22 +0100 |
---|---|---|
committer | Nadrieril | 2020-04-05 11:43:22 +0100 |
commit | 15a0902b50ff6d1b36dbf7a220b6ff42ceefada6 (patch) | |
tree | bf9239a9d222499f2e0c6d2781651a006d6511ce | |
parent | 158117e4096f5af571e79e1a33d91f09e7b2cc5d (diff) |
Rename Deserialize trait to FromDhall
Diffstat (limited to '')
-rw-r--r-- | serde_dhall/src/deserialize.rs | 4 | ||||
-rw-r--r-- | serde_dhall/src/lib.rs | 2 | ||||
-rw-r--r-- | serde_dhall/src/options.rs | 4 | ||||
-rw-r--r-- | serde_dhall/src/shortcuts.rs | 4 | ||||
-rw-r--r-- | serde_dhall/src/value.rs | 8 | ||||
-rw-r--r-- | serde_dhall/tests/de.rs | 6 |
6 files changed, 14 insertions, 14 deletions
diff --git a/serde_dhall/src/deserialize.rs b/serde_dhall/src/deserialize.rs index b9b711c..1be68c4 100644 --- a/serde_dhall/src/deserialize.rs +++ b/serde_dhall/src/deserialize.rs @@ -36,7 +36,7 @@ pub trait Sealed {} /// ``` /// /// [serde]: https://serde.rs -pub trait Deserialize: Sealed + Sized { +pub trait FromDhall: Sealed + Sized { #[doc(hidden)] fn from_dhall(v: &Value) -> Result<Self>; } @@ -45,7 +45,7 @@ impl<T> Sealed for T where T: serde::de::DeserializeOwned {} struct Deserializer<'a>(Cow<'a, SimpleValue>); -impl<T> Deserialize for T +impl<T> FromDhall for T where T: serde::de::DeserializeOwned, { diff --git a/serde_dhall/src/lib.rs b/serde_dhall/src/lib.rs index 71274b6..9f99adb 100644 --- a/serde_dhall/src/lib.rs +++ b/serde_dhall/src/lib.rs @@ -172,7 +172,7 @@ mod value; #[doc(hidden)] pub use dhall_proc_macros::StaticType; -pub use deserialize::Deserialize; +pub use deserialize::FromDhall; pub(crate) use deserialize::Sealed; pub(crate) use error::ErrorKind; pub use error::{Error, Result}; diff --git a/serde_dhall/src/options.rs b/serde_dhall/src/options.rs index 237647f..d7a91a2 100644 --- a/serde_dhall/src/options.rs +++ b/serde_dhall/src/options.rs @@ -3,7 +3,7 @@ use std::path::{Path, PathBuf}; use dhall::Parsed; use crate::SimpleType; -use crate::{Deserialize, Error, ErrorKind, Result, StaticType, Value}; +use crate::{FromDhall, Error, ErrorKind, Result, StaticType, Value}; #[derive(Debug, Clone)] enum Source<'a> { @@ -128,7 +128,7 @@ impl<'a, T> Deserializer<'a, T> { /// TODO pub fn parse(&self) -> Result<T> where - T: Deserialize, + T: FromDhall, { let val = self._parse().map_err(ErrorKind::Dhall).map_err(Error)?; T::from_dhall(&val) diff --git a/serde_dhall/src/shortcuts.rs b/serde_dhall/src/shortcuts.rs index cd31402..9c9ce9f 100644 --- a/serde_dhall/src/shortcuts.rs +++ b/serde_dhall/src/shortcuts.rs @@ -1,7 +1,7 @@ use doc_comment::doc_comment; use std::path::Path; -use crate::{options, Deserialize, Result, SimpleType, StaticType}; +use crate::{options, FromDhall, Result, SimpleType, StaticType}; // Avoid copy-pasting documentation @@ -252,7 +252,7 @@ macro_rules! generate_fn { gen_doc!($src, $ty), pub fn $name<T, $($ty_params)*> ($($input_args)*) -> Result<T> where - T: Deserialize $($extra_bounds)*, + T: FromDhall $($extra_bounds)*, { $($create_options)* .parse() } diff --git a/serde_dhall/src/value.rs b/serde_dhall/src/value.rs index 3543f4d..fee9d73 100644 --- a/serde_dhall/src/value.rs +++ b/serde_dhall/src/value.rs @@ -3,7 +3,7 @@ use std::collections::{BTreeMap, HashMap}; use dhall::semantics::{Hir, HirKind, Nir, NirKind}; use dhall::syntax::{Builtin, Expr, ExprKind, NumKind, Span}; -use crate::{Deserialize, Error, ErrorKind, Result, Sealed}; +use crate::{FromDhall, Error, ErrorKind, Result, Sealed}; #[doc(hidden)] /// An arbitrary Dhall value. @@ -246,12 +246,12 @@ impl Sealed for Value {} impl Sealed for SimpleValue {} impl Sealed for SimpleType {} -impl Deserialize for Value { +impl FromDhall for Value { fn from_dhall(v: &Value) -> Result<Self> { Ok(v.clone()) } } -impl Deserialize for SimpleValue { +impl FromDhall for SimpleValue { fn from_dhall(v: &Value) -> Result<Self> { v.to_simple_value().ok_or_else(|| { Error(ErrorKind::Deserialize(format!( @@ -261,7 +261,7 @@ impl Deserialize for SimpleValue { }) } } -impl Deserialize for SimpleType { +impl FromDhall for SimpleType { fn from_dhall(v: &Value) -> Result<Self> { v.to_simple_type().ok_or_else(|| { Error(ErrorKind::Deserialize(format!( diff --git a/serde_dhall/tests/de.rs b/serde_dhall/tests/de.rs index 653613a..8afba6e 100644 --- a/serde_dhall/tests/de.rs +++ b/serde_dhall/tests/de.rs @@ -1,9 +1,9 @@ use serde::Deserialize; -use serde_dhall::{from_str, from_str_static_type, StaticType}; +use serde_dhall::{from_str, FromDhall, from_str_static_type, StaticType}; #[test] fn test_de_typed() { - fn parse<T: serde_dhall::Deserialize + StaticType>(s: &str) -> T { + fn parse<T: FromDhall + StaticType>(s: &str) -> T { from_str_static_type(s).unwrap() } @@ -57,7 +57,7 @@ fn test_de_typed() { #[test] fn test_de_untyped() { - fn parse<T: serde_dhall::Deserialize>(s: &str) -> T { + fn parse<T: FromDhall>(s: &str) -> T { from_str(s).unwrap() } |