summaryrefslogtreecommitdiff
path: root/dhall/src/lib.rs
diff options
context:
space:
mode:
authorNadrieril2019-04-13 00:44:58 +0200
committerNadrieril2019-04-13 00:44:58 +0200
commite7e79bf32c385fa8c30a45be262ca3d6d8f1f653 (patch)
tree769651e0c22c9d15069f8fee24c82a3eecfb1f1d /dhall/src/lib.rs
parentca0939f4cdf373ca735f25926d0a02c698d7f1cf (diff)
Document all of the API
Closes #64
Diffstat (limited to 'dhall/src/lib.rs')
-rw-r--r--dhall/src/lib.rs17
1 files changed, 16 insertions, 1 deletions
diff --git a/dhall/src/lib.rs b/dhall/src/lib.rs
index 73f3c1b..51fb6b7 100644
--- a/dhall/src/lib.rs
+++ b/dhall/src/lib.rs
@@ -13,7 +13,7 @@
//! [Dhall][dhall] is a programmable configuration language that provides a non-repetitive
//! alternative to JSON and YAML.
//!
-//! You can think of Dhall as: JSON/YAML + types + imports + functions
+//! You can think of Dhall as: JSON + types + imports + functions
//!
//! For a description of the dhall language, examples, tutorials, and more, see the [language
//! website][dhall].
@@ -130,10 +130,19 @@ mod typecheck;
pub use crate::traits::{Deserialize, SimpleStaticType, StaticType};
#[doc(hidden)]
pub use dhall_generator::SimpleStaticType;
+/// When manipulating Dhall expressions goes wrong.
pub mod error;
pub mod expr;
mod serde;
+/// Deserialize an instance of type T from a string of Dhall text.
+///
+/// This will recursively resolve all imports in the expression, and
+/// typecheck it. More control over this process is not yet available
+/// but will be in a coming verions 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::expr::Type>,
@@ -141,6 +150,12 @@ pub fn from_str<'a, T: Deserialize<'a>>(
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. More control over this process is not yet available
+/// but will be in a coming verions of this crate.
pub fn from_str_auto_type<'a, T: Deserialize<'a> + StaticType>(
s: &'a str,
) -> crate::error::Result<T> {