Sequential, disk-backed commit log library for Rust. The library can be used in various higher-level distributed abstractions on top of a distributed log such as Paxos, Chain Replication or Raft.
First, add this to your Cargo.toml:
[dependencies]
commitlog = "0.2"use commitlog::*;use commitlog::message::*;fnmain(){// open a directory called 'log' for segment and index storagelet opts = LogOptions::new("log");letmut log = CommitLog::new(opts).unwrap();// append to the log
log.append_msg("hello world").unwrap();// offset 0
log.append_msg("second message").unwrap();// offset 1// read the messageslet messages = log.read(0,ReadLimit::default()).unwrap();for msg in messages.iter(){println!("{} - {}", msg.offset(),String::from_utf8_lossy(msg.payload()));}// prints:// 0 - hello world// 1 - second message}