summary refs log tree commit diff stats
path: root/src/pattern.rs
diff options
context:
space:
mode:
authorSoniEx2 <endermoneymod@gmail.com>2022-09-04 20:45:19 -0300
committerSoniEx2 <endermoneymod@gmail.com>2022-09-04 20:45:19 -0300
commit937774ee1d172cf47a7fc12e435b7dd7c6464aaf (patch)
tree6ab0173d47997852c0054715d59421cc0b81d46a /src/pattern.rs
parentf24123f943abaebffd098a12069bcca62181f862 (diff)
Initial work on Serde VM stuff
Diffstat (limited to 'src/pattern.rs')
-rw-r--r--src/pattern.rs15
1 files changed, 9 insertions, 6 deletions
diff --git a/src/pattern.rs b/src/pattern.rs
index 2e69714..fc3c8a7 100644
--- a/src/pattern.rs
+++ b/src/pattern.rs
@@ -6,16 +6,17 @@
 use std::borrow::Borrow;
 use std::collections::BTreeMap;
 
-use serde::Deserialize;
-use serde::Deserializer;
-use serde::Serialize;
+use serde::de::Deserialize;
+use serde::de::DeserializeSeed;
+use serde::de::Deserializer;
+use serde::ser::Serialize;
 
 use crate::Predicate;
 use crate::errors::PatternError;
 use crate::parser::parse;
-//use crate::vm::Matcher;
+use crate::vm;
 use crate::vm::PatternConstants;
-//use crate::vm::MAX_CALLS;
+use crate::vm::MAX_CALLS;
 
 /// A compiled Datafu pattern.
 ///
@@ -83,11 +84,13 @@ impl<O: Serialize> Pattern<O> {
     }
 
     /// Matches the pattern against an input.
-    pub fn deserialize<'de, Der, De>(&self, de: Der) -> Result<De, Der::Error>
+    pub fn deserialize<'de, Der, De>(&self, der: Der) -> Result<De, Der::Error>
     where
         Der: Deserializer<'de>,
         De: Deserialize<'de>,
     {
+        let pack = vm::Packer::new(&self.consts, MAX_CALLS).deserialize(der)?;
+        let de = De::deserialize(vm::Unpacker::new(pack, MAX_CALLS));
         todo!()
     }
 }