Permalink
Browse files

Apparently it's impossible to decode without fdsets

  • Loading branch information...
sevagh committed Mar 30, 2017
1 parent 3f3c274 commit 9d10d70c7acef6fad34f5d53c92a2a4aa58bac4b
Showing with 18 additions and 9 deletions.
  1. +18 −9 src/protob.rs
View
@@ -1,23 +1,18 @@
use std::env;
use std::fs::File;
use std::io::Read;
use serde::de::Deserialize;
use serde_protobuf::descriptor::Descriptors;
use serde_protobuf::de::Deserializer;
use serde_protobuf::value::Message;
use serde_value::Value;
use protobuf::{CodedInputStream, parse_from_reader};
static UNKNOWN_FDSET: &'static [u8] = b"
*
\runknown.protoxyz.sevag.pqrs\"
Unknown";
pub fn process_single(read: &mut Read) {
let proto = parse_from_reader(&mut UNKNOWN_FDSET.clone()).unwrap();
let proto = parse_from_reader(&mut open_combined_fdset()).unwrap();
let descriptors = Descriptors::from_proto(&proto);
let byte_is = CodedInputStream::new(read);
let mut deserializer = Deserializer::for_named_message(&descriptors, ".xyz.sevag.pqrs.Unknown", byte_is).unwrap();
let mut deserializer = Deserializer::for_named_message(&descriptors, ".com.example.dog.Dog", byte_is).unwrap();
let value = Value::deserialize(&mut deserializer).unwrap();
println!("{:?}", value);
}
@@ -34,3 +29,17 @@ pub fn process_stream(read: &mut Read) {
}
}
}
fn open_combined_fdset() -> File {
let mut home = match env::home_dir() {
Some(home) => home,
None => panic!("Could not find $HOME"),
};
home.push(".pq/combined.fdset");
match File::open(home.as_path()) {
Ok(x) => return x,
Err(e) => panic!(e),
}
}

0 comments on commit 9d10d70

Please sign in to comment.