diff options
Diffstat (limited to 'src/type_tree.rs')
-rw-r--r-- | src/type_tree.rs | 46 |
1 files changed, 44 insertions, 2 deletions
diff --git a/src/type_tree.rs b/src/type_tree.rs index b1faa54..e7389d5 100644 --- a/src/type_tree.rs +++ b/src/type_tree.rs @@ -38,7 +38,7 @@ //! match a `Foo`, but more efficiently than with a predicate. Another big //! difference between predicates and type trees is how predicates are eager, //! and can consume values that would otherwise be matched by the rest of a -//! pattern. +//! pattern, like `IgnoredAny`. //! //! Type trees are pretty flexible. Consider the following example: //! @@ -67,4 +67,46 @@ //! struct visitor will error. But despite the error, it'll still create a type //! tree for the `deserialize_struct`! -// TODO +// use serde::Deserializer; + +// /// A deserializer which attempts to fill in a type tree. +// struct TypeTreeDeserializer<'tt, D> { +// inner: D, +// tt: &'tt mut TypeTreeNode, +// } + +/// A Type Tree entry type. +/// +/// This represents a type to be deserialized with Serde, with everything that +/// comes with that. It supports the 29 core Serde types, and 2 self-describing +/// ones. +#[derive(Clone, Debug, PartialEq, Eq, Hash, Default)] +pub enum TypeTreeType { + /// An open type, which can be anything. + /// + /// This represents [`Deserializer::deserialize_any`]. + #[default] + Any, + /// A type for a value which will be ignored. + /// + /// This represents [`Deserializer::deserialize_ignored_any`]. + IgnoredAny, + Bool, +} + +/// A node of a type tree. +#[derive(Clone, Debug, PartialEq, Eq, Hash, Default)] +pub struct TypeTreeNode { + /// The type to be requested for this node. + pub node_type: TypeTreeType, + /// The types for when this node is an enum. + pub enum_nodes: (), // TODO + /// The types for when this node is a map. + pub map_nodes: (), // TODO + /// The types for when this node is a seq. + pub seq_nodes: (), // TODO + /// The type for when this node is a some. + pub some_node: Option<Box<TypeTreeNode>>, + /// The type for when this node is a newtype struct. + pub newtype_node: Option<Box<TypeTreeNode>>, +} |