summary refs log tree commit diff stats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/errors.rs12
-rw-r--r--src/graph.rs7
-rw-r--r--src/lib.rs1
-rw-r--r--src/pattern.rs1
-rw-r--r--src/vm/de/mod.rs1
-rw-r--r--src/vm/de/unpacker.rs10
6 files changed, 17 insertions, 15 deletions
diff --git a/src/errors.rs b/src/errors.rs
index ea1e60d..2c8b2e5 100644
--- a/src/errors.rs
+++ b/src/errors.rs
@@ -57,21 +57,21 @@ pub enum MatchError {
      Unsatisfiable,
 }
 
+/// Error returned while unwrapping a `Graph`.
 #[derive(Debug)]
 #[non_exhaustive]
-pub enum QueryError {
+pub enum UnpackError {
      /// Returned if the deserialization recurses too deeply.
     StackOverflow,
     /// Returned if there's nothing to deserialize.
     Empty,
-    /// The query is unsatisfiable. This happens if e.g. there are multiple
-    /// values in the query but only one value can fit into the request.
+    /// The packed data is incompatible with the data structure.
     Unsatisfiable,
     /// Wrapped Serde error.
     Serde(serde::de::value::Error),
 }
 
-impl std::fmt::Display for QueryError {
+impl std::fmt::Display for UnpackError {
     fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
         match self {
             Self::StackOverflow => write!(f, "stack overflow"),
@@ -82,10 +82,10 @@ impl std::fmt::Display for QueryError {
     }
 }
 
-impl std::error::Error for QueryError {
+impl std::error::Error for UnpackError {
 }
 
-impl serde::de::Error for QueryError {
+impl serde::de::Error for UnpackError {
     fn custom<T>(msg: T) -> Self where T: std::fmt::Display {
         Self::Serde(serde::de::value::Error::custom(msg))
     }
diff --git a/src/graph.rs b/src/graph.rs
index 47d6523..c95cf34 100644
--- a/src/graph.rs
+++ b/src/graph.rs
@@ -8,19 +8,20 @@ use serde::de::Deserialize;
 use crate::vm::MAX_CALLS;
 use crate::vm::Pack;
 use crate::vm::Unpacker;
-use crate::errors::QueryError;
+use crate::errors::UnpackError;
 
 // TODO in the future, we may want to store &'pat IndexSet<String> either here
 // or in the Pack.
+/// Match results. Produced by matching a `Pattern` against a `Deserializer`.
 #[derive(Debug)]
 pub struct Graph<'pat, 'de>(pub(crate) Option<Pack<'pat, 'de>>);
 
 impl<'pat, 'de> Graph<'pat, 'de> {
     /// Collect this graph into a given form.
-    pub fn collect<De: Deserialize<'de>>(self) -> Result<De, QueryError> {
+    pub fn collect<De: Deserialize<'de>>(self) -> Result<De, UnpackError> {
         let Self(inner) = self;
         match inner {
-            None => Err(QueryError::Empty),
+            None => Err(UnpackError::Empty),
             Some(pack) => {
                 let mut unpacker = Unpacker::new(pack, MAX_CALLS);
                 De::deserialize(unpacker)
diff --git a/src/lib.rs b/src/lib.rs
index 27d6c30..fa9f9e7 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -116,6 +116,7 @@ mod parser;
 mod pattern;
 mod vm;
 
+pub use graph::Graph;
 pub use pattern::Pattern;
 pub use pattern::PatternBuilder;
 
diff --git a/src/pattern.rs b/src/pattern.rs
index 23d427e..a684cff 100644
--- a/src/pattern.rs
+++ b/src/pattern.rs
@@ -64,6 +64,7 @@ impl<O: Serialize> Pattern<O> {
     }
 }
 
+/// Builder for [`Pattern`].
 pub struct PatternBuilder<'s, PKey=&'static str, OKey=&'static str, O=()> {
     input: &'s str,
     preds: Option<BTreeMap<PKey, Box<Predicate>>>,
diff --git a/src/vm/de/mod.rs b/src/vm/de/mod.rs
index 3cba18a..45274eb 100644
--- a/src/vm/de/mod.rs
+++ b/src/vm/de/mod.rs
@@ -23,7 +23,6 @@ use super::SerdeObject;
 use super::Type;
 use super::Value;
 use crate::errors::MatchError;
-use crate::errors::QueryError;
 
 mod unpacker;
 
diff --git a/src/vm/de/unpacker.rs b/src/vm/de/unpacker.rs
index 8b16aa3..ce2e0d0 100644
--- a/src/vm/de/unpacker.rs
+++ b/src/vm/de/unpacker.rs
@@ -9,7 +9,7 @@ use std::collections::hash_map::IntoIter as HMIntoIter;
 use serde::de::IntoDeserializer;
 use serde::de::value::StrDeserializer;
 
-use crate::errors::QueryError;
+use crate::errors::UnpackError;
 use crate::vm::Pack;
 
 /// A `Deserializer` for Datafu output.
@@ -54,7 +54,7 @@ impl<'pat, 'de> Unpacker<'pat, 'de> {
 }
 
 impl<'pat, 'de> serde::de::SeqAccess<'de> for Unpacker<'pat, 'de> {
-    type Error = QueryError;
+    type Error = UnpackError;
 
     fn next_element_seed<T: serde::de::DeserializeSeed<'de>>(
         &mut self,
@@ -81,7 +81,7 @@ impl Drop for UnpackerFields<'_, '_, '_> {
 }
 
 impl<'pat, 'de> serde::de::MapAccess<'de> for UnpackerFields<'_, 'pat, 'de> {
-    type Error = QueryError;
+    type Error = UnpackError;
     fn next_key_seed<T: serde::de::DeserializeSeed<'de>>(
         &mut self,
         seed: T,
@@ -108,7 +108,7 @@ impl<'pat, 'de> serde::de::MapAccess<'de> for UnpackerFields<'_, 'pat, 'de> {
 }
 
 impl<'pat, 'de> serde::Deserializer<'de> for &mut Unpacker<'pat, 'de> {
-    type Error = QueryError;
+    type Error = UnpackError;
     fn deserialize_any<V>(self, _: V) -> Result<V::Value, Self::Error> where V: serde::de::Visitor<'de> { todo!() }
     fn deserialize_bool<V>(self, _: V) -> Result<V::Value, Self::Error> where V: serde::de::Visitor<'de> { todo!() }
     fn deserialize_i8<V>(self, _: V) -> Result<V::Value, Self::Error> where V: serde::de::Visitor<'de> { todo!() }
@@ -192,7 +192,7 @@ impl<'pat, 'de> serde::Deserializer<'de> for &mut Unpacker<'pat, 'de> {
 }
 
 impl<'pat, 'de> serde::Deserializer<'de> for Unpacker<'pat, 'de> {
-    type Error = QueryError;
+    type Error = UnpackError;
     fn deserialize_any<V>(self, _: V) -> Result<V::Value, Self::Error> where V: serde::de::Visitor<'de> { todo!() }
     fn deserialize_bool<V>(self, _: V) -> Result<V::Value, Self::Error> where V: serde::de::Visitor<'de> { todo!() }
     fn deserialize_i8<V>(self, _: V) -> Result<V::Value, Self::Error> where V: serde::de::Visitor<'de> { todo!() }