Skip to content

Commit

Permalink
Merge pull request #16 from garious/add-serde
Browse files Browse the repository at this point in the history
Add serialization/deseriation support to event log
  • Loading branch information
garious committed Feb 20, 2018
2 parents bd84cf6 + fa4e232 commit 49605b2
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 6 deletions.
4 changes: 3 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,6 @@ asm = ["sha2-asm"]
rayon = "1.0.0"
sha2 = "0.7.0"
sha2-asm = {version="0.3", optional=true}
digest = "0.7.2"
generic-array = { version = "0.9.0", default-features = false, features = ["serde"] }
serde = "1.0.27"
serde_derive = "1.0.27"
5 changes: 4 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
#![cfg_attr(feature = "unstable", feature(test))]
pub mod log;
pub mod historian;
extern crate digest;
extern crate generic_array;
extern crate rayon;
extern crate serde;
#[macro_use]
extern crate serde_derive;
extern crate sha2;
8 changes: 4 additions & 4 deletions src/log.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@
/// fastest processor. Duration should therefore be estimated by assuming that the hash
/// was generated by the fastest processor at the time the entry was logged.

use digest::generic_array::GenericArray;
use digest::generic_array::typenum::U32;
use generic_array::GenericArray;
use generic_array::typenum::U32;
pub type Sha256Hash = GenericArray<u8, U32>;

#[derive(Debug, PartialEq, Eq, Clone)]
#[derive(Serialize, Deserialize, Debug, PartialEq, Eq, Clone)]
pub struct Entry {
pub num_hashes: u64,
pub end_hash: Sha256Hash,
Expand All @@ -29,7 +29,7 @@ pub struct Entry {
/// be generated in 'num_hashes' hashes and verified in 'num_hashes' hashes. By logging
/// a hash alongside the tick, each tick and be verified in parallel using the 'end_hash'
/// of the preceding tick to seed its hashing.
#[derive(Debug, PartialEq, Eq, Clone)]
#[derive(Serialize, Deserialize, Debug, PartialEq, Eq, Clone)]
pub enum Event {
Tick,
UserDataKey(Sha256Hash),
Expand Down

0 comments on commit 49605b2

Please sign in to comment.