summaryrefslogtreecommitdiff
path: root/dhall/src/api/traits
diff options
context:
space:
mode:
authorNadrieril2019-05-09 22:27:17 +0200
committerNadrieril2019-05-09 22:27:17 +0200
commit7ac061b5ddf15ffe3fc4f36b64138b7431429758 (patch)
treed77fd6945e67a317ba5a8b1dc3229984d65e4e3d /dhall/src/api/traits
parentdae106b3de0888e8a704c0efa3f9d991590f7858 (diff)
Rewrite Deserialize trait around new Value and Type
Diffstat (limited to 'dhall/src/api/traits')
-rw-r--r--dhall/src/api/traits/deserialize.rs53
-rw-r--r--dhall/src/api/traits/mod.rs2
2 files changed, 0 insertions, 55 deletions
diff --git a/dhall/src/api/traits/deserialize.rs b/dhall/src/api/traits/deserialize.rs
deleted file mode 100644
index 9673cf9..0000000
--- a/dhall/src/api/traits/deserialize.rs
+++ /dev/null
@@ -1,53 +0,0 @@
-use crate::error::*;
-use crate::phase::*;
-
-/// A data structure that can be deserialized from a Dhall expression
-///
-/// This is automatically implemented for any type that [serde][serde]
-/// can deserialize.
-///
-/// This trait cannot be implemented manually.
-pub trait Deserialize<'de>: Sized {
- /// See [dhall::de::from_str][crate::de::from_str]
- fn from_str(s: &'de str, ty: Option<&Type>) -> Result<Self>;
-}
-
-impl<'de> Deserialize<'de> for Parsed {
- /// Simply parses the provided string. Ignores the
- /// provided type.
- fn from_str(s: &'de str, _: Option<&Type>) -> Result<Self> {
- Ok(Parsed::parse_str(s)?)
- }
-}
-
-impl<'de> Deserialize<'de> for Resolved {
- /// Parses and resolves the provided string. Ignores the
- /// provided type.
- fn from_str(s: &'de str, ty: Option<&Type>) -> Result<Self> {
- Ok(Parsed::from_str(s, ty)?.resolve()?)
- }
-}
-
-impl<'de> Deserialize<'de> for Typed {
- /// Parses, resolves and typechecks the provided string.
- fn from_str(s: &'de str, ty: Option<&Type>) -> Result<Self> {
- let resolved = Resolved::from_str(s, ty)?;
- match ty {
- None => Ok(resolved.typecheck()?),
- Some(t) => Ok(resolved.typecheck_with(t)?),
- }
- }
-}
-
-impl<'de> Deserialize<'de> for Normalized {
- /// Parses, resolves, typechecks and normalizes the provided string.
- fn from_str(s: &'de str, ty: Option<&Type>) -> Result<Self> {
- Ok(Typed::from_str(s, ty)?.normalize())
- }
-}
-
-impl<'de> Deserialize<'de> for Type {
- fn from_str(s: &'de str, ty: Option<&Type>) -> Result<Self> {
- Ok(Normalized::from_str(s, ty)?.to_type())
- }
-}
diff --git a/dhall/src/api/traits/mod.rs b/dhall/src/api/traits/mod.rs
deleted file mode 100644
index 3fd21e4..0000000
--- a/dhall/src/api/traits/mod.rs
+++ /dev/null
@@ -1,2 +0,0 @@
-mod deserialize;
-pub use deserialize::Deserialize;