summaryrefslogtreecommitdiff
path: root/serde_dhall
diff options
context:
space:
mode:
Diffstat (limited to 'serde_dhall')
-rw-r--r--serde_dhall/src/deserialize.rs3
-rw-r--r--serde_dhall/src/error.rs2
-rw-r--r--serde_dhall/src/lib.rs5
-rw-r--r--serde_dhall/src/options.rs9
-rw-r--r--serde_dhall/src/shortcuts.rs4
-rw-r--r--serde_dhall/src/simple.rs2
-rw-r--r--serde_dhall/src/static_type.rs1
-rw-r--r--serde_dhall/src/value.rs3
8 files changed, 25 insertions, 4 deletions
diff --git a/serde_dhall/src/deserialize.rs b/serde_dhall/src/deserialize.rs
index 75a08a9..cccadad 100644
--- a/serde_dhall/src/deserialize.rs
+++ b/serde_dhall/src/deserialize.rs
@@ -16,9 +16,10 @@ pub trait Sealed {}
/// can deserialize.
///
/// This trait cannot be implemented manually.
+///
+/// TODO
pub trait Deserialize: Sealed + Sized {
#[doc(hidden)]
- /// See [serde_dhall::from_str][crate::from_str]
fn from_dhall(v: &Value) -> Result<Self>;
}
diff --git a/serde_dhall/src/error.rs b/serde_dhall/src/error.rs
index 91a0b94..23d1b02 100644
--- a/serde_dhall/src/error.rs
+++ b/serde_dhall/src/error.rs
@@ -1,9 +1,11 @@
use dhall::error::Error as DhallError;
+/// TODO
pub type Result<T> = std::result::Result<T, Error>;
#[derive(Debug)]
#[non_exhaustive]
+/// TODO
pub enum Error {
Dhall(DhallError),
Deserialize(String),
diff --git a/serde_dhall/src/lib.rs b/serde_dhall/src/lib.rs
index 5ee1cf6..e59255c 100644
--- a/serde_dhall/src/lib.rs
+++ b/serde_dhall/src/lib.rs
@@ -1,6 +1,5 @@
#![doc(html_root_url = "https://docs.rs/serde_dhall/0.4.0")]
-// #![warn(missing_docs)]
-// #![warn(missing_doc_code_examples)]
+// TODO #![warn(missing_docs)] #![warn(missing_doc_code_examples)]
//! [Dhall][dhall] is a programmable configuration language that provides a non-repetitive
//! alternative to JSON and YAML.
//!
@@ -173,7 +172,7 @@
#[cfg(doctest)]
doc_comment::doctest!("../../README.md");
-/// Finer-grained control over deserializing Dhall
+/// Finer-grained control over deserializing Dhall values
pub mod options;
/// Serde-compatible Dhall values and their type
pub mod simple;
diff --git a/serde_dhall/src/options.rs b/serde_dhall/src/options.rs
index 542804b..19b8587 100644
--- a/serde_dhall/src/options.rs
+++ b/serde_dhall/src/options.rs
@@ -48,6 +48,7 @@ enum Source<'a> {
/// # Ok(())
/// # }
/// ```
+/// /// TODO
#[derive(Debug, Clone)]
pub struct Options<'a, T> {
source: Source<'a>,
@@ -69,9 +70,11 @@ impl<'a, T> Options<'a, T> {
target_type: std::marker::PhantomData,
}
}
+ /// TODO
fn from_str(s: &'a str) -> Self {
Self::default_with_source(Source::Str(s))
}
+ /// TODO
fn from_file<P: AsRef<Path>>(path: P) -> Self {
Self::default_with_source(Source::File(path.as_ref().to_owned()))
}
@@ -79,6 +82,7 @@ impl<'a, T> Options<'a, T> {
// Self::default_with_source(Source::Url(url))
// }
+ /// TODO
pub fn imports(&mut self, imports: bool) -> &mut Self {
self.allow_imports = imports;
self
@@ -90,10 +94,12 @@ impl<'a, T> Options<'a, T> {
// }
// self
// }
+ // /// TODO
pub fn type_annotation(&mut self, ty: &SimpleType) -> &mut Self {
self.annot = Some(ty.clone());
self
}
+ /// TODO
pub fn static_type_annotation(&mut self) -> &mut Self
where
T: StaticType,
@@ -118,6 +124,7 @@ impl<'a, T> Options<'a, T> {
};
Ok(Value::from_nir(typed.normalize().as_nir()))
}
+ /// TODO
pub fn parse(&self) -> Result<T>
where
T: Deserialize,
@@ -127,9 +134,11 @@ impl<'a, T> Options<'a, T> {
}
}
+/// TODO
pub fn from_str<'a, T>(s: &'a str) -> Options<'a, T> {
Options::from_str(s)
}
+/// TODO
pub fn from_file<'a, T, P: AsRef<Path>>(path: P) -> Options<'a, T> {
Options::from_file(path)
}
diff --git a/serde_dhall/src/shortcuts.rs b/serde_dhall/src/shortcuts.rs
index 1fb1032..ddb738c 100644
--- a/serde_dhall/src/shortcuts.rs
+++ b/serde_dhall/src/shortcuts.rs
@@ -79,6 +79,8 @@ where
/// # Ok(())
/// # }
/// ```
+///
+/// TODO
pub fn from_str_manual_type<T>(s: &str, ty: &SimpleType) -> Result<T>
where
T: Deserialize,
@@ -92,6 +94,8 @@ where
/// Like [from_str], but this additionally checks that
/// the type of the provided expression matches the output type `T`. The [StaticType] trait
/// captures Rust types that are valid Dhall types.
+///
+/// TODO
pub fn from_str_static_type<T>(s: &str) -> Result<T>
where
T: Deserialize + StaticType,
diff --git a/serde_dhall/src/simple.rs b/serde_dhall/src/simple.rs
index 95642bd..3d77853 100644
--- a/serde_dhall/src/simple.rs
+++ b/serde_dhall/src/simple.rs
@@ -6,6 +6,7 @@ use dhall::syntax::{Builtin, ExprKind, NumKind, Span};
use crate::{Deserialize, Error, Result, Sealed};
/// A simple value of the kind that can be encoded/decoded with serde
+/// TODO
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct Value {
kind: Box<ValKind>,
@@ -24,6 +25,7 @@ pub enum ValKind {
}
/// The type of a `simple::Value`.
+/// TODO
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct Type {
kind: Box<TyKind>,
diff --git a/serde_dhall/src/static_type.rs b/serde_dhall/src/static_type.rs
index 79418d2..3fdff39 100644
--- a/serde_dhall/src/static_type.rs
+++ b/serde_dhall/src/static_type.rs
@@ -11,6 +11,7 @@ use crate::simple::{TyKind, Type};
/// For this reason, something like `HashMap<String, bool>` cannot implement
/// [StaticType] because each different value would
/// have a different Dhall record type.
+/// TODO
pub trait StaticType {
fn static_type() -> Type;
}
diff --git a/serde_dhall/src/value.rs b/serde_dhall/src/value.rs
index a119028..2557efe 100644
--- a/serde_dhall/src/value.rs
+++ b/serde_dhall/src/value.rs
@@ -5,6 +5,7 @@ use crate::simple::{Type as SimpleType, Value as SimpleValue};
use crate::{Deserialize, Error, Sealed};
/// An arbitrary Dhall value.
+/// TODO
#[derive(Debug, Clone)]
pub struct Value {
/// Invariant: in normal form
@@ -25,10 +26,12 @@ impl Value {
}
/// Converts a Value into a SimpleValue.
+ /// TODO
pub fn to_simple_value(&self) -> Option<SimpleValue> {
self.as_simple_val.clone()
}
/// Converts a Value into a SimpleType.
+ /// TODO
pub fn to_simple_type(&self) -> Option<SimpleType> {
self.as_simple_ty.clone()
}