diff options
author | Nadrieril | 2019-05-06 23:21:19 +0200 |
---|---|---|
committer | Nadrieril | 2019-05-06 23:21:19 +0200 |
commit | 5b91eaa9d6b70a2ac72fe19f2d21871c8d94b017 (patch) | |
tree | 9ab6c6025d8f994c1ca10db1c4b8ea7d39087290 /dhall | |
parent | 60129b7d1c0ea8bdf2ec666fa51957e97465e88f (diff) |
Move api-related modules into an api module
Diffstat (limited to '')
-rw-r--r-- | dhall/src/api/mod.rs | 38 | ||||
-rw-r--r-- | dhall/src/api/serde.rs (renamed from dhall/src/serde.rs) | 0 | ||||
-rw-r--r-- | dhall/src/api/traits/deserialize.rs (renamed from dhall/src/traits/deserialize.rs) | 0 | ||||
-rw-r--r-- | dhall/src/api/traits/dynamic_type.rs (renamed from dhall/src/traits/dynamic_type.rs) | 0 | ||||
-rw-r--r-- | dhall/src/api/traits/mod.rs (renamed from dhall/src/traits/mod.rs) | 0 | ||||
-rw-r--r-- | dhall/src/api/traits/static_type.rs (renamed from dhall/src/traits/static_type.rs) | 0 | ||||
-rw-r--r-- | dhall/src/lib.rs | 41 |
7 files changed, 41 insertions, 38 deletions
diff --git a/dhall/src/api/mod.rs b/dhall/src/api/mod.rs new file mode 100644 index 0000000..1522c9c --- /dev/null +++ b/dhall/src/api/mod.rs @@ -0,0 +1,38 @@ +mod serde; +pub(crate) mod traits; + +/// Deserialization of Dhall expressions into Rust +pub mod de { + pub use crate::traits::{Deserialize, SimpleStaticType, StaticType}; + #[doc(hidden)] + pub use dhall_proc_macros::SimpleStaticType; + + /// Deserialize an instance of type T from a string of Dhall text. + /// + /// This will recursively resolve all imports in the expression, and + /// typecheck it before deserialization. Relative imports will be resolved relative to the + /// provided file. More control over this process is not yet available + /// but will be in a coming version of this crate. + /// + /// If a type is provided, this additionally checks that the provided + /// expression has that type. + pub fn from_str<'a, T: Deserialize<'a>>( + s: &'a str, + ty: Option<&crate::phase::Type>, + ) -> crate::error::Result<T> { + T::from_str(s, ty) + } + + /// Deserialize an instance of type T from a string of Dhall text, + /// additionally checking that it matches the type of T. + /// + /// This will recursively resolve all imports in the expression, and + /// typecheck it before deserialization. Relative imports will be resolved relative to the + /// provided file. More control over this process is not yet available + /// but will be in a coming version of this crate. + pub fn from_str_auto_type<'a, T: Deserialize<'a> + StaticType>( + s: &'a str, + ) -> crate::error::Result<T> { + from_str(s, Some(&<T as StaticType>::get_static_type())) + } +} diff --git a/dhall/src/serde.rs b/dhall/src/api/serde.rs index 93921ba..93921ba 100644 --- a/dhall/src/serde.rs +++ b/dhall/src/api/serde.rs diff --git a/dhall/src/traits/deserialize.rs b/dhall/src/api/traits/deserialize.rs index 9673cf9..9673cf9 100644 --- a/dhall/src/traits/deserialize.rs +++ b/dhall/src/api/traits/deserialize.rs diff --git a/dhall/src/traits/dynamic_type.rs b/dhall/src/api/traits/dynamic_type.rs index 7763a28..7763a28 100644 --- a/dhall/src/traits/dynamic_type.rs +++ b/dhall/src/api/traits/dynamic_type.rs diff --git a/dhall/src/traits/mod.rs b/dhall/src/api/traits/mod.rs index 315e17a..315e17a 100644 --- a/dhall/src/traits/mod.rs +++ b/dhall/src/api/traits/mod.rs diff --git a/dhall/src/traits/static_type.rs b/dhall/src/api/traits/static_type.rs index 8b141a0..8b141a0 100644 --- a/dhall/src/traits/static_type.rs +++ b/dhall/src/api/traits/static_type.rs diff --git a/dhall/src/lib.rs b/dhall/src/lib.rs index 9f9c315..989170a 100644 --- a/dhall/src/lib.rs +++ b/dhall/src/lib.rs @@ -123,43 +123,8 @@ #[macro_use] mod tests; +mod api; pub mod error; mod phase; -mod serde; -mod traits; - -/// Deserialization of Dhall expressions into Rust -pub mod de { - pub use crate::traits::{Deserialize, SimpleStaticType, StaticType}; - #[doc(hidden)] - pub use dhall_proc_macros::SimpleStaticType; - - /// Deserialize an instance of type T from a string of Dhall text. - /// - /// This will recursively resolve all imports in the expression, and - /// typecheck it before deserialization. Relative imports will be resolved relative to the - /// provided file. More control over this process is not yet available - /// but will be in a coming version of this crate. - /// - /// If a type is provided, this additionally checks that the provided - /// expression has that type. - pub fn from_str<'a, T: Deserialize<'a>>( - s: &'a str, - ty: Option<&crate::phase::Type>, - ) -> crate::error::Result<T> { - T::from_str(s, ty) - } - - /// Deserialize an instance of type T from a string of Dhall text, - /// additionally checking that it matches the type of T. - /// - /// This will recursively resolve all imports in the expression, and - /// typecheck it before deserialization. Relative imports will be resolved relative to the - /// provided file. More control over this process is not yet available - /// but will be in a coming version of this crate. - pub fn from_str_auto_type<'a, T: Deserialize<'a> + StaticType>( - s: &'a str, - ) -> crate::error::Result<T> { - from_str(s, Some(&<T as StaticType>::get_static_type())) - } -} +pub use api::de; +pub(crate) use api::traits; |