aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/bin/geniza-register.rs54
-rw-r--r--src/bin/geniza-sleep.rs34
-rw-r--r--src/lib.rs16
-rw-r--r--src/metadata_msg.proto (renamed from src/drive_proto.proto)0
-rw-r--r--src/metadata_msg.rs (renamed from src/drive_proto.rs)0
-rw-r--r--src/network_msg.rs (renamed from src/network_proto.rs)0
-rw-r--r--src/network_msgs.proto (renamed from src/network_proto.proto)0
-rw-r--r--src/protocol.rs (renamed from src/sync.rs)4
-rw-r--r--src/sleep_file.rs (renamed from src/sleep.rs)0
-rw-r--r--src/sleep_register.rs (renamed from src/register.rs)2
10 files changed, 39 insertions, 71 deletions
diff --git a/src/bin/geniza-register.rs b/src/bin/geniza-register.rs
deleted file mode 100644
index a328bbc..0000000
--- a/src/bin/geniza-register.rs
+++ /dev/null
@@ -1,54 +0,0 @@
-
-#[macro_use]
-extern crate error_chain;
-extern crate clap;
-extern crate env_logger;
-extern crate geniza;
-
-// TODO: more careful import
-use geniza::*;
-use std::path::Path;
-use clap::{App, SubCommand};
-
-fn run() -> Result<()> {
-
- env_logger::init().unwrap();
-
- let matches = App::new("geniza-register")
- .version(env!("CARGO_PKG_VERSION"))
- .subcommand(SubCommand::with_name("info")
- .about("Reads a SLEEP dir register and shows some basic metadata")
- .arg_from_usage("<DIR> 'directory containing files'")
- .arg_from_usage("<prefix> 'prefix for each data file'"))
- .subcommand(SubCommand::with_name("create")
- .about("Creates an SLEEP directory register (with header)")
- .arg_from_usage("<DIR> 'directory containing files'")
- .arg_from_usage("<prefix> 'prefix for each data file'"))
- .get_matches();
-
-
- match matches.subcommand() {
- ("info", Some(subm)) => {
- let dir = Path::new(subm.value_of("DIR").unwrap());
- let prefix = subm.value_of("prefix").unwrap();
- let mut sdr = SleepDirRegister::open(dir, prefix, false)?;
- //debug!(println!("{:?}", sdr));
- println!("Entry count: {}", sdr.len()?);
- println!("Total size (bytes): {}", sdr.len_bytes()?);
- },
- ("create", Some(subm)) => {
- let dir = Path::new(subm.value_of("DIR").unwrap());
- let prefix = subm.value_of("prefix").unwrap();
- SleepDirRegister::create(dir, prefix)?;
- println!("Done!");
- },
- _ => {
- println!("Missing or unimplemented command!");
- println!("{}", matches.usage());
- ::std::process::exit(-1);
- },
- }
- Ok(())
-}
-
-quick_main!(run);
diff --git a/src/bin/geniza-sleep.rs b/src/bin/geniza-sleep.rs
index 10fc16b..17ff91b 100644
--- a/src/bin/geniza-sleep.rs
+++ b/src/bin/geniza-sleep.rs
@@ -18,22 +18,44 @@ fn run() -> Result<()> {
let matches = App::new("geniza-sleep")
.version(env!("CARGO_PKG_VERSION"))
.subcommand(SubCommand::with_name("info")
- .about("Reads a SLEEP file and shows some basic metadata")
- .arg_from_usage("<FILE> 'SLEEP file to read'"))
+ .about("Reads a SLEEP dir register and shows some basic metadata")
+ .arg_from_usage("<DIR> 'directory containing files'")
+ .arg_from_usage("<prefix> 'prefix for each data file'"))
.subcommand(SubCommand::with_name("create")
- .about("Creates an empty SLEEP file (with header)")
+ .about("Creates an SLEEP directory register (with header)")
+ .arg_from_usage("<DIR> 'directory containing files'")
+ .arg_from_usage("<prefix> 'prefix for each data file'"))
+ .subcommand(SubCommand::with_name("file-info")
+ .about("Reads a single SLEEP file and shows some basic metadata")
+ .arg_from_usage("<FILE> 'SLEEP file to read'"))
+ .subcommand(SubCommand::with_name("file-create")
+ .about("Creates an empty single SLEEP file (with header)")
.arg_from_usage("<FILE> 'SLEEP file to write (can't exist)'")
.arg_from_usage("<magic> 'Magic word to use (eg, 0x5025700)'")
.arg_from_usage("<entry_size> 'Size of each entry (bytes)'")
.arg_from_usage("<algo_name> 'Name of algorithm (empty string for none)'"))
.subcommand(SubCommand::with_name("read-all")
- .about("Reads a SLEEP file, iterates through all entries, prints raw bytes")
+ .about("Reads a single SLEEP file, iterates through all entries, prints raw bytes")
.arg_from_usage("<FILE> 'SLEEP file to read'"))
.get_matches();
match matches.subcommand() {
("info", Some(subm)) => {
+ let dir = Path::new(subm.value_of("DIR").unwrap());
+ let prefix = subm.value_of("prefix").unwrap();
+ let mut sdr = SleepDirRegister::open(dir, prefix, false)?;
+ //debug!(println!("{:?}", sdr));
+ println!("Entry count: {}", sdr.len()?);
+ println!("Total size (bytes): {}", sdr.len_bytes()?);
+ },
+ ("create", Some(subm)) => {
+ let dir = Path::new(subm.value_of("DIR").unwrap());
+ let prefix = subm.value_of("prefix").unwrap();
+ SleepDirRegister::create(dir, prefix)?;
+ println!("Done!");
+ },
+ ("file-info", Some(subm)) => {
let path = Path::new(subm.value_of("FILE").unwrap());
let sf = SleepFile::open(path, false)?;
//debug!(println!("{:?}", sf));
@@ -42,7 +64,7 @@ fn run() -> Result<()> {
println!("Entry Size (bytes): {}", sf.get_entry_size());
println!("Entry count: {}", sf.len()?);
},
- ("create", Some(subm)) => {
+ ("file-create", Some(subm)) => {
let path = Path::new(subm.value_of("FILE").unwrap());
let algo_name = subm.value_of("algo_name").unwrap();
let algo_name = if algo_name.len() == 0 {
@@ -57,7 +79,7 @@ fn run() -> Result<()> {
algo_name)?;
println!("Done!");
},
- ("read-all", Some(subm)) => {
+ ("file-read-all", Some(subm)) => {
let path = Path::new(subm.value_of("FILE").unwrap());
let mut sf = SleepFile::open(path, false)?;
for i in 0..sf.len()? {
diff --git a/src/lib.rs b/src/lib.rs
index fbbe50a..3fd39ac 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -40,11 +40,11 @@ mod errors {
pub use errors::*;
// Organize code internally (files, modules), but pull it all into a flat namespace to export.
-mod sleep;
-pub use sleep::*;
-mod register;
-pub use register::*;
-mod sync;
-pub use sync::*;
-pub mod network_proto;
-pub mod drive_proto;
+mod sleep_file;
+pub use sleep_file::*;
+mod sleep_register;
+pub use sleep_register::*;
+mod protocol;
+pub use protocol::*;
+pub mod network_msg;
+pub mod metadata_msg;
diff --git a/src/drive_proto.proto b/src/metadata_msg.proto
index cd36b30..cd36b30 100644
--- a/src/drive_proto.proto
+++ b/src/metadata_msg.proto
diff --git a/src/drive_proto.rs b/src/metadata_msg.rs
index c30833a..c30833a 100644
--- a/src/drive_proto.rs
+++ b/src/metadata_msg.rs
diff --git a/src/network_proto.rs b/src/network_msg.rs
index e9dae76..e9dae76 100644
--- a/src/network_proto.rs
+++ b/src/network_msg.rs
diff --git a/src/network_proto.proto b/src/network_msgs.proto
index 1b7bc2c..1b7bc2c 100644
--- a/src/network_proto.proto
+++ b/src/network_msgs.proto
diff --git a/src/sync.rs b/src/protocol.rs
index efa045a..7a64f88 100644
--- a/src/sync.rs
+++ b/src/protocol.rs
@@ -12,8 +12,8 @@ use protobuf::parse_from_bytes;
use integer_encoding::{VarIntReader, VarIntWriter};
use errors::*;
-use network_proto::*;
-use drive_proto::Index;
+use network_msg::*;
+use metadata_msg::Index;
#[derive(Debug)]
pub enum DatNetMessage {
diff --git a/src/sleep.rs b/src/sleep_file.rs
index 36bf7a9..36bf7a9 100644
--- a/src/sleep.rs
+++ b/src/sleep_file.rs
diff --git a/src/register.rs b/src/sleep_register.rs
index 0313497..e798cad 100644
--- a/src/register.rs
+++ b/src/sleep_register.rs
@@ -11,7 +11,7 @@ use crypto::ed25519;
use rand::{Rng, OsRng};
use errors::*;
-use sleep::*;
+use sleep_file::*;
/// Abstract access to Hypercore register
pub trait HyperRegister {