Skip to content
This repository was archived by the owner on Jan 22, 2025. It is now read-only.

Commit 49605b2

Browse files
authored
Merge pull request #16 from garious/add-serde
Add serialization/deseriation support to event log
2 parents bd84cf6 + fa4e232 commit 49605b2

File tree

3 files changed

+11
-6
lines changed

3 files changed

+11
-6
lines changed

Cargo.toml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,4 +26,6 @@ asm = ["sha2-asm"]
2626
rayon = "1.0.0"
2727
sha2 = "0.7.0"
2828
sha2-asm = {version="0.3", optional=true}
29-
digest = "0.7.2"
29+
generic-array = { version = "0.9.0", default-features = false, features = ["serde"] }
30+
serde = "1.0.27"
31+
serde_derive = "1.0.27"

src/lib.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
#![cfg_attr(feature = "unstable", feature(test))]
22
pub mod log;
33
pub mod historian;
4-
extern crate digest;
4+
extern crate generic_array;
55
extern crate rayon;
6+
extern crate serde;
7+
#[macro_use]
8+
extern crate serde_derive;
69
extern crate sha2;

src/log.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,11 @@
1313
/// fastest processor. Duration should therefore be estimated by assuming that the hash
1414
/// was generated by the fastest processor at the time the entry was logged.
1515
16-
use digest::generic_array::GenericArray;
17-
use digest::generic_array::typenum::U32;
16+
use generic_array::GenericArray;
17+
use generic_array::typenum::U32;
1818
pub type Sha256Hash = GenericArray<u8, U32>;
1919

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

0 commit comments

Comments
 (0)