summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitignore2
-rw-r--r--Cargo.toml4
-rw-r--r--src/lib.rs7
-rw-r--r--vndbapi-msg/Cargo.toml7
-rw-r--r--vndbapi-msg/src/lib.rs6
-rw-r--r--vndbapi-msg/src/msg.rs (renamed from src/msg.rs)0
-rw-r--r--vndbapi-msg/src/parser.rs (renamed from src/parser.rs)9
7 files changed, 25 insertions, 10 deletions
diff --git a/.gitignore b/.gitignore
index a9d37c5..2745baf 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,2 +1,4 @@
target
Cargo.lock
+vndbapi-msg/target
+vndbapi-msg/Cargo.lock
diff --git a/Cargo.toml b/Cargo.toml
index a7390a2..1a0e2c2 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -4,8 +4,8 @@ version = "0.1.0"
authors = ["Yorhel <projects@yorhel.nl>"]
[dependencies]
+vndbapi-msg = { path="vndbapi-msg" }
rustls = "0.5.3"
lazy_static = "0.2.2"
-webpki = "0.8.0" # Must be the same as used by rustls
+webpki = "0.10.0" # Must be the same as used by rustls
netbuf = "0.3.8"
-serde_json = "0.8.4"
diff --git a/src/lib.rs b/src/lib.rs
index c09ab0b..195158f 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -2,14 +2,11 @@
extern crate rustls;
extern crate webpki;
extern crate netbuf;
-extern crate serde_json;
+extern crate vndbapi_msg as msg;
mod conn;
-mod parser;
-
-pub mod msg;
-pub use conn::Connection;
+pub use conn::*;
static LE_ROOT: [webpki::TrustAnchor<'static>; 2] = [
// ISRG Root X1 - The Let's Encrypt root cert
diff --git a/vndbapi-msg/Cargo.toml b/vndbapi-msg/Cargo.toml
new file mode 100644
index 0000000..05655f1
--- /dev/null
+++ b/vndbapi-msg/Cargo.toml
@@ -0,0 +1,7 @@
+[package]
+name = "vndbapi-msg"
+version = "0.1.0"
+authors = ["Yorhel <projects@yorhel.nl>"]
+
+[dependencies]
+serde_json = "0.9.8"
diff --git a/vndbapi-msg/src/lib.rs b/vndbapi-msg/src/lib.rs
new file mode 100644
index 0000000..d36199c
--- /dev/null
+++ b/vndbapi-msg/src/lib.rs
@@ -0,0 +1,6 @@
+extern crate serde_json;
+
+mod parser;
+mod msg;
+
+pub use msg::*;
diff --git a/src/msg.rs b/vndbapi-msg/src/msg.rs
index ead8ac0..ead8ac0 100644
--- a/src/msg.rs
+++ b/vndbapi-msg/src/msg.rs
diff --git a/src/parser.rs b/vndbapi-msg/src/parser.rs
index 0644e45..135c71d 100644
--- a/src/parser.rs
+++ b/vndbapi-msg/src/parser.rs
@@ -9,12 +9,15 @@ type Result<T> = ::std::result::Result<T, &'static str>;
/* Parse a JSON value with trailing data. This is a workaround until a proper solution has
* been implemented: https://github.com/serde-rs/json/issues/183 */
fn parse_json(s: &str) -> Result<(Value, &str)> {
+ println!("Parsing JSON: {}", s);
let mut bytes = 0;
- let val: Value = ::serde_json::de::StreamDeserializer::new(s.bytes().map(|b| { bytes += 1; Ok(b)} ))
- .next().ok_or("Expected JSON value")?.map_err(|_| "Invalid JSON value")?;
+ let val: Value = ::serde_json::Deserializer::from_iter(s.bytes().map(|b| { bytes += 1; Ok(b)} ))
+ .into_iter().next()
+ .ok_or("Expected JSON value")?
+ .map_err(|_| "Invalid JSON value")?;
// The JSON deserializer consumes one extra byte for numeric types, subtract that.
- match val { Value::I64(_) | Value::U64(_) | Value::F64(_) => bytes -= 1, _ => () };
+ match val { Value::Number(_) => bytes -= 1, _ => () };
Ok((val, &s[bytes..]))
}