diff options
Diffstat (limited to 'serde_dhall/src/options')
-rw-r--r-- | serde_dhall/src/options/de.rs | 48 | ||||
-rw-r--r-- | serde_dhall/src/options/ser.rs | 36 |
2 files changed, 36 insertions, 48 deletions
diff --git a/serde_dhall/src/options/de.rs b/serde_dhall/src/options/de.rs index 30846a2..103f161 100644 --- a/serde_dhall/src/options/de.rs +++ b/serde_dhall/src/options/de.rs @@ -19,15 +19,12 @@ enum Source<'a> { /// This builder exposes the ability to configure how a value is deserialized and what operations /// are permitted during evaluation. /// -/// Generally speaking, when using [`Deserializer`], you'll create it with [`from_str`] or [`from_file`], then -/// chain calls to methods to set each option, then call [`parse`]. This will give you a -/// [`Result<T>`] where `T` is a deserializable type of your choice. +/// Generally speaking, when using [`Deserializer`], you'll create it with [`from_str()`] or +/// [`from_file()`], then chain calls to methods to set each option, then call [`parse()`]. This +/// will give you a [`Result<T>`] where `T` is a deserializable type of your choice. /// -/// [`Deserializer`]: struct.Deserializer.html -/// [`from_str`]: fn.from_str.html -/// [`from_file`]: fn.from_file.html -/// [`parse`]: struct.Deserializer.html#method.parse -/// [`Result<T>`]: type.Result.html +/// [`parse()`]: Deserializer::parse() +/// [`Result<T>`]: Result /// /// # Examples /// @@ -91,7 +88,7 @@ impl<'a> Deserializer<'a, NoAnnot> { /// Ensures that the parsed value matches the provided type. /// /// In many cases the Dhall type that corresponds to a Rust type can be inferred automatically. - /// See the [`StaticType`] trait and the [`static_type_annotation`] method for that. + /// See the [`StaticType`] trait and the [`static_type_annotation()`] method for that. /// /// # Example /// @@ -124,8 +121,8 @@ impl<'a> Deserializer<'a, NoAnnot> { /// # } /// ``` /// - /// [`static_type_annotation`]: struct.Deserializer.html#method.static_type_annotation - /// [`StaticType`]: trait.StaticType.html + /// [`StaticType`]: crate::StaticType + /// [`static_type_annotation()`]: Deserializer::static_type_annotation() pub fn type_annotation<'ty>( self, ty: &'ty SimpleType, @@ -139,8 +136,8 @@ impl<'a> Deserializer<'a, NoAnnot> { /// Ensures that the parsed value matches the type of `T`. /// - /// `T` must implement the [`StaticType`] trait. If it doesn't, you can use [`type_annotation`] - /// to provide a type manually. + /// `T` must implement the [`StaticType`] trait. If it doesn't, you can use + /// [`type_annotation()`] to provide a type manually. /// /// # Example /// @@ -177,8 +174,8 @@ impl<'a> Deserializer<'a, NoAnnot> { /// # } /// ``` /// - /// [`type_annotation`]: struct.Deserializer.html#method.type_annotation - /// [`StaticType`]: trait.StaticType.html + /// [`StaticType`]: crate::StaticType + /// [`type_annotation()`]: Deserializer::type_annotation() pub fn static_type_annotation(self) -> Deserializer<'a, StaticAnnot> { Deserializer { annot: StaticAnnot, @@ -210,9 +207,6 @@ impl<'a, A> Deserializer<'a, A> { /// # Ok(()) /// # } /// ``` - /// - /// [`static_type_annotation`]: struct.Deserializer.html#method.static_type_annotation - /// [`StaticType`]: trait.StaticType.html pub fn imports(self, imports: bool) -> Self { Deserializer { allow_imports: imports, @@ -271,7 +265,8 @@ impl<'a, A> Deserializer<'a, A> { /// # Ok(()) /// # } /// ``` - /// [`StaticType`]: trait.StaticType.html + /// + /// [`StaticType`]: crate::StaticType pub fn parse<T>(&self) -> Result<T> where A: TypeAnnot, @@ -287,7 +282,7 @@ impl<'a, A> Deserializer<'a, A> { /// Deserialize a value from a string of Dhall text. /// -/// This returns a [`Deserializer`] object. Call the [`parse`] method to get the deserialized +/// This returns a [`Deserializer`] object. Call the [`parse()`] method to get the deserialized /// value, or use other [`Deserializer`] methods to control the deserialization process. /// /// Imports will be resolved relative to the current directory. @@ -317,15 +312,14 @@ impl<'a, A> Deserializer<'a, A> { /// # } /// ``` /// -/// [`Deserializer`]: struct.Deserializer.html -/// [`parse`]: struct.Deserializer.html#method.parse +/// [`parse()`]: Deserializer::parse() pub fn from_str(s: &str) -> Deserializer<'_, NoAnnot> { Deserializer::from_str(s) } /// Deserialize a value from a Dhall file. /// -/// This returns a [`Deserializer`] object. Call the [`parse`] method to get the deserialized +/// This returns a [`Deserializer`] object. Call the [`parse()`] method to get the deserialized /// value, or use other [`Deserializer`] methods to control the deserialization process. /// /// Imports will be resolved relative to the provided file's path. @@ -349,8 +343,7 @@ pub fn from_str(s: &str) -> Deserializer<'_, NoAnnot> { /// # } /// ``` /// -/// [`Deserializer`]: struct.Deserializer.html -/// [`parse`]: struct.Deserializer.html#method.parse +/// [`parse()`]: Deserializer::parse() pub fn from_file<'a, P: AsRef<Path>>(path: P) -> Deserializer<'a, NoAnnot> { Deserializer::from_file(path) } @@ -359,7 +352,7 @@ pub fn from_file<'a, P: AsRef<Path>>(path: P) -> Deserializer<'a, NoAnnot> { /// the Dhall standard specification and is mostly used for caching expressions. Using the format /// is not recommended because errors won't have a file to refer to and thus will be hard to fix. /// -/// This returns a [`Deserializer`] object. Call the [`parse`] method to get the deserialized +/// This returns a [`Deserializer`] object. Call the [`parse()`] method to get the deserialized /// value, or use other [`Deserializer`] methods to control the deserialization process. /// /// Imports will be resolved relative to the provided file's path. @@ -383,8 +376,7 @@ pub fn from_file<'a, P: AsRef<Path>>(path: P) -> Deserializer<'a, NoAnnot> { /// # } /// ``` /// -/// [`Deserializer`]: struct.Deserializer.html -/// [`parse`]: struct.Deserializer.html#method.parse +/// [`parse()`]: Deserializer::parse() pub fn from_binary_file<'a, P: AsRef<Path>>( path: P, ) -> Deserializer<'a, NoAnnot> { diff --git a/serde_dhall/src/options/ser.rs b/serde_dhall/src/options/ser.rs index d74beb0..d2c173b 100644 --- a/serde_dhall/src/options/ser.rs +++ b/serde_dhall/src/options/ser.rs @@ -6,17 +6,14 @@ use crate::{Result, SimpleType, ToDhall}; /// This builder exposes the ability to configure how a value is serialized, and to set type /// annotations. /// -/// When using [`Serializer`], you'll create it with [`serialize`], then chain calls to methods to -/// set each option, then call [`to_string`]. This will give you a [`Result<String>`] containing -/// the input serialized to Dhall. +/// When using [`Serializer`], you'll create it with [`serialize()`], then chain calls to methods +/// to set each option, then call [`to_string()`]. This will give you a [`Result`] containing the +/// input serialized to Dhall. /// /// Note that if you do not provide a type annotation, some values may not be convertible to Dhall, /// like empty lists or enums. /// -/// [`Serializer`]: struct.Serializer.html -/// [`serialize`]: fn.serialize.html -/// [`to_string`]: struct.Serializer.html#method.to_string -/// [`Result<String>`]: type.Result.html +/// [`to_string()`]: Serializer::to_string() /// /// # Examples /// @@ -56,7 +53,7 @@ impl<'a, T> Serializer<'a, T, NoAnnot> { /// unions. /// /// In many cases the Dhall type that corresponds to a Rust type can be inferred automatically. - /// See the [`StaticType`] trait and the [`static_type_annotation`] method for that. + /// See the [`StaticType`] trait and the [`static_type_annotation()`] method for that. /// /// # Example /// @@ -83,8 +80,8 @@ impl<'a, T> Serializer<'a, T, NoAnnot> { /// # } /// ``` /// - /// [`static_type_annotation`]: struct.Serializer.html#method.static_type_annotation - /// [`StaticType`]: trait.StaticType.html + /// [`StaticType`]: crate::StaticType + /// [`static_type_annotation()`]: Serializer::static_type_annotation() pub fn type_annotation<'ty>( self, ty: &'ty SimpleType, @@ -98,7 +95,7 @@ impl<'a, T> Serializer<'a, T, NoAnnot> { /// Uses the type of `T` in the serialization process. This will be used when Dhall needs it, /// like for empty lists or for unions. /// - /// `T` must implement the [`StaticType`] trait. If it doesn't, you can use [`type_annotation`] + /// `T` must implement the [`StaticType`] trait. If it doesn't, you can use [`type_annotation()`] /// /// # Example /// @@ -124,8 +121,8 @@ impl<'a, T> Serializer<'a, T, NoAnnot> { /// # } /// ``` /// - /// [`type_annotation`]: struct.Serializer.html#method.type_annotation - /// [`StaticType`]: trait.StaticType.html + /// [`StaticType`]: crate::StaticType + /// [`type_annotation()`]: Serializer::type_annotation() pub fn static_type_annotation(self) -> Serializer<'a, T, StaticAnnot> { Serializer { annot: StaticAnnot, @@ -158,7 +155,7 @@ where /// # } /// ``` /// - /// [`StaticType`]: trait.StaticType.html + /// [`StaticType`]: crate::StaticType pub fn to_string(&self) -> Result<String> where T: ToDhall + HasAnnot<A>, @@ -170,11 +167,11 @@ where /// Serialize a value to a string of Dhall text. /// -/// This returns a [`Serializer`] object. Call the [`to_string`] method to get the serialized +/// This returns a [`Serializer`] object. Call the [`to_string()`] method to get the serialized /// value, or use other [`Serializer`] methods to control the serialization process. /// /// In order to process certain values (like unions or empty lists) correctly, it is necessary to -/// add a type annotation (with [`static_type_annotation`] or [`type_annotation`]). +/// add a type annotation (with [`static_type_annotation()`] or [`type_annotation()`]). /// /// # Examples /// @@ -219,10 +216,9 @@ where /// # } /// ``` /// -/// [`Serializer`]: struct.Serializer.html -/// [`type_annotation`]: struct.Serializer.html#method.type_annotation -/// [`static_type_annotation`]: struct.Serializer.html#method.static_type_annotation -/// [`to_string`]: struct.Serializer.html#method.to_string +/// [`type_annotation()`]: Serializer::type_annotation() +/// [`static_type_annotation()`]: Serializer::static_type_annotation() +/// [`to_string()`]: Serializer::to_string() pub fn serialize<T>(data: &T) -> Serializer<'_, T, NoAnnot> where T: ToDhall, |