Add Debug auto implementation to io structs

master
trivernis 5 years ago
parent 0620f1a682
commit 6f2ea29725

@ -1,6 +1,6 @@
[package] [package]
name = "bdflib" name = "bdflib"
version = "0.3.3" version = "0.3.4"
authors = ["trivernis <trivernis@gmail.com>"] authors = ["trivernis <trivernis@gmail.com>"]
edition = "2018" edition = "2018"
license-file = "LICENSE" license-file = "LICENSE"

@ -11,6 +11,7 @@ use crossbeam_utils::sync::WaitGroup;
const ENTRIES_PER_CHUNK: u32 = 100_000; const ENTRIES_PER_CHUNK: u32 = 100_000;
#[derive(Debug)]
struct ThreadManager<T1, T2> { struct ThreadManager<T1, T2> {
pub sender_work: Option<Sender<T1>>, pub sender_work: Option<Sender<T1>>,
pub receiver_work: Receiver<T1>, pub receiver_work: Receiver<T1>,
@ -20,6 +21,7 @@ struct ThreadManager<T1, T2> {
pub threads_started: bool, pub threads_started: bool,
} }
#[derive(Debug)]
pub struct BDFReader { pub struct BDFReader {
reader: BufReader<File>, reader: BufReader<File>,
pub metadata: Option<MetaChunk>, pub metadata: Option<MetaChunk>,
@ -27,6 +29,7 @@ pub struct BDFReader {
compressed: bool, compressed: bool,
} }
#[derive(Debug)]
pub struct BDFWriter { pub struct BDFWriter {
writer: BufWriter<File>, writer: BufWriter<File>,
metadata: MetaChunk, metadata: MetaChunk,
@ -107,6 +110,7 @@ impl BDFWriter {
s.send(chunk.serialize()).expect("failed to send result"); s.send(chunk.serialize()).expect("failed to send result");
} }
drop(wg); drop(wg);
drop(s);
} }
}); });
} }

@ -36,8 +36,9 @@ mod tests {
#[test] #[test]
fn it_writes_compressed() -> Result<(), Error> { 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_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(FOO.to_string(), 4))?;
writer.add_lookup_entry(HashEntry::new(BAR.to_string(), 5))?; 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]); entry_2.add_hash_value(FOO.to_string(), vec![4, 5, 2, 3]);
writer.add_data_entry(entry_2)?; 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()?; writer.finish()?;
remove_file("tmp2.bdf")?; remove_file("tmp2.bdf")?;

Loading…
Cancel
Save