Skip to content

Instantly share code, notes, and snippets.

@saarw
Created June 27, 2017 21:43
Show Gist options
  • Save saarw/d18770d209f156ddb53c9e366cd22abd to your computer and use it in GitHub Desktop.
Save saarw/d18770d209f156ddb53c9e366cd22abd to your computer and use it in GitHub Desktop.
use erased_serde;
use serde_json;
#[derive(Serialize)]
struct Event {
data_point: usize
}
#[derive(Serialize)]
struct Batch {
field1: String,
field2: String,
events: Vec<Box<erased_serde::Serialize>>
}
fn serialize_batch(events: Vec<Box<erased_serde::Serialize>>) -> String {
serde_json::to_string(&Batch{field1: "a".to_string(), field2: "b".to_string(), events: events}).unwrap()
}
#[test]
fn test_serialize() {
assert!(serialize_batch(vec!(Box::new(Event{data_point: 13}))).len() > 0);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment