From 6f2ea297258d5d22ccad7e0178783469a46c59bd Mon Sep 17 00:00:00 2001 From: trivernis Date: Sun, 15 Mar 2020 11:12:46 +0100 Subject: [PATCH] Add Debug auto implementation to io structs --- Cargo.toml | 2 +- src/io.rs | 4 ++++ src/lib.rs | 8 +++++++- 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 0acc814..d92a888 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "bdflib" -version = "0.3.3" +version = "0.3.4" authors = ["trivernis "] edition = "2018" license-file = "LICENSE" diff --git a/src/io.rs b/src/io.rs index 104350e..f2aa775 100644 --- a/src/io.rs +++ b/src/io.rs @@ -11,6 +11,7 @@ use crossbeam_utils::sync::WaitGroup; const ENTRIES_PER_CHUNK: u32 = 100_000; +#[derive(Debug)] struct ThreadManager { pub sender_work: Option>, pub receiver_work: Receiver, @@ -20,6 +21,7 @@ struct ThreadManager { pub threads_started: bool, } +#[derive(Debug)] pub struct BDFReader { reader: BufReader, pub metadata: Option, @@ -27,6 +29,7 @@ pub struct BDFReader { compressed: bool, } +#[derive(Debug)] pub struct BDFWriter { writer: BufWriter, metadata: MetaChunk, @@ -107,6 +110,7 @@ impl BDFWriter { s.send(chunk.serialize()).expect("failed to send result"); } drop(wg); + drop(s); } }); } diff --git a/src/lib.rs b/src/lib.rs index c8220bf..038a8b1 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -36,8 +36,9 @@ mod tests { #[test] fn it_writes_compressed() -> Result<(), Error> { - let mut writer = new_writer("tmp2.bdf", 2, true)?; + let mut writer = new_writer("tmp2.bdf", 3, true)?; writer.set_compression_level(3); + writer.set_entries_per_chunk(2)?; writer.add_lookup_entry(HashEntry::new(FOO.to_string(), 4))?; writer.add_lookup_entry(HashEntry::new(BAR.to_string(), 5))?; @@ -52,6 +53,11 @@ mod tests { entry_2.add_hash_value(FOO.to_string(), vec![4, 5, 2, 3]); writer.add_data_entry(entry_2)?; + let mut entry_3 = DataEntry::new("lool".to_string()); + entry_3.add_hash_value(BAR.to_string(), vec![1, 3, 2, 1, 5]); + entry_3.add_hash_value(FOO.to_string(), vec![5, 5, 2, 3]); + writer.add_data_entry(entry_3)?; + writer.finish()?; remove_file("tmp2.bdf")?;