From 5b91eaa9d6b70a2ac72fe19f2d21871c8d94b017 Mon Sep 17 00:00:00 2001 From: Nadrieril Date: Mon, 6 May 2019 23:21:19 +0200 Subject: Move api-related modules into an api module --- dhall/src/traits/deserialize.rs | 53 ----------------------------------------- 1 file changed, 53 deletions(-) delete mode 100644 dhall/src/traits/deserialize.rs (limited to 'dhall/src/traits/deserialize.rs') diff --git a/dhall/src/traits/deserialize.rs b/dhall/src/traits/deserialize.rs deleted file mode 100644 index 9673cf9..0000000 --- a/dhall/src/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; -} - -impl<'de> Deserialize<'de> for Parsed { - /// Simply parses the provided string. Ignores the - /// provided type. - fn from_str(s: &'de str, _: Option<&Type>) -> Result { - 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 { - 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 { - 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 { - Ok(Typed::from_str(s, ty)?.normalize()) - } -} - -impl<'de> Deserialize<'de> for Type { - fn from_str(s: &'de str, ty: Option<&Type>) -> Result { - Ok(Normalized::from_str(s, ty)?.to_type()) - } -} -- cgit v1.2.3