1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#![crate_type = "lib"]
#![deny(missing_docs)]
pub use vclock::VClock;
pub use orswot::Orswot;
pub use lwwreg::LWWReg;
pub use gcounter::GCounter;
pub mod lwwreg;
pub mod vclock;
pub mod orswot;
pub mod gcounter;
extern crate rustc_serialize;
extern crate bincode;
extern crate quickcheck;
extern crate rand;
#[macro_use] extern crate maplit;
use bincode::SizeLimit;
use bincode::rustc_serialize::{encode, decode, DecodingResult};
use rustc_serialize::{Encodable, Decodable};
pub fn to_binary<A: Encodable>(s: &A) -> Vec<u8> {
encode(s, SizeLimit::Infinite).unwrap()
}
pub fn from_binary<A: Decodable>(encoded: Vec<u8>) -> DecodingResult<A> {
decode(&encoded[..])
}