diff --git a/Readme.md b/Readme.md index 1bac3dc..3281a3d 100644 --- a/Readme.md +++ b/Readme.md @@ -40,7 +40,7 @@ Measuring with the 'time' utility the original zstd and my decoder both decoding The easiest is to use the provided `compress`/`compress_to_vec` functions ```rust, no_run -use ruzstd::encoding::{compress, compress_to_vec, frame_compressor::CompressionLevel}; +use ruzstd::encoding::{compress, compress_to_vec, CompressionLevel}; let data: &[u8] = todo!(); // Either let mut compressed = Vec::new(); @@ -60,7 +60,7 @@ Additionally to the descriptions and the docs you can have a look at the zstd / The easiest is to wrap the io::Read into a StreamingDecoder which itself implements io::Read. It will decode blocks as necessary to fulfill the read requests ```rust, no_run -use ruzstd::decoding::streaming_decoder::StreamingDecoder; +use ruzstd::decoding::StreamingDecoder; use ruzstd::io::Read; let mut source: &[u8] = todo!("Get a reader from a File or any other source"); diff --git a/benches/decode_all.rs b/benches/decode_all.rs index 08be96f..e7f89cd 100644 --- a/benches/decode_all.rs +++ b/benches/decode_all.rs @@ -1,5 +1,5 @@ use criterion::{criterion_group, criterion_main, Criterion}; -use ruzstd::decoding::frame_decoder::FrameDecoder; +use ruzstd::decoding::FrameDecoder; fn criterion_benchmark(c: &mut Criterion) { let mut fr = FrameDecoder::new(); diff --git a/fuzz/fuzz_targets/decode.rs b/fuzz/fuzz_targets/decode.rs index 2e60d8c..9fff7b8 100644 --- a/fuzz/fuzz_targets/decode.rs +++ b/fuzz/fuzz_targets/decode.rs @@ -5,7 +5,7 @@ extern crate ruzstd; use std::io::Read; fuzz_target!(|data: &[u8]| { - if let Ok(mut decoder) = ruzstd::decoding::streaming_decoder::StreamingDecoder::new(data) { + if let Ok(mut decoder) = ruzstd::decoding::StreamingDecoder::new(data) { let mut output = Vec::new(); _ = decoder.read_to_end(&mut output); } diff --git a/fuzz/fuzz_targets/encode.rs b/fuzz/fuzz_targets/encode.rs index 5c763be..7048bef 100644 --- a/fuzz/fuzz_targets/encode.rs +++ b/fuzz/fuzz_targets/encode.rs @@ -2,7 +2,7 @@ #[macro_use] extern crate libfuzzer_sys; extern crate ruzstd; -use ruzstd::encoding::frame_compressor::{CompressionLevel, FrameCompressor}; +use ruzstd::encoding::{CompressionLevel, FrameCompressor}; fuzz_target!(|data: &[u8]| { let mut output = Vec::new(); @@ -10,7 +10,7 @@ fuzz_target!(|data: &[u8]| { compressor.compress(); let mut decoded = Vec::with_capacity(data.len()); - let mut decoder = ruzstd::decoding::frame_decoder::FrameDecoder::new(); + let mut decoder = ruzstd::decoding::FrameDecoder::new(); decoder.decode_all_to_vec(&output, &mut decoded).unwrap(); assert_eq!(data, &decoded); @@ -19,7 +19,7 @@ fuzz_target!(|data: &[u8]| { compressor.compress(); let mut decoded = Vec::with_capacity(data.len()); - let mut decoder = ruzstd::decoding::frame_decoder::FrameDecoder::new(); + let mut decoder = ruzstd::decoding::FrameDecoder::new(); decoder.decode_all_to_vec(&output, &mut decoded).unwrap(); assert_eq!(data, &decoded); }); diff --git a/fuzz/fuzz_targets/interop.rs b/fuzz/fuzz_targets/interop.rs index 588e35b..fb22f42 100644 --- a/fuzz/fuzz_targets/interop.rs +++ b/fuzz/fuzz_targets/interop.rs @@ -5,21 +5,21 @@ extern crate ruzstd; use std::io::Read; fn decode_ruzstd(data: &mut dyn std::io::Read) -> Vec { - let mut decoder = ruzstd::decoding::streaming_decoder::StreamingDecoder::new(data).unwrap(); + let mut decoder = ruzstd::decoding::StreamingDecoder::new(data).unwrap(); let mut result: Vec = Vec::new(); decoder.read_to_end(&mut result).expect("Decoding failed"); result } fn decode_ruzstd_writer(mut data: impl Read) -> Vec { - let mut decoder = ruzstd::decoding::frame_decoder::FrameDecoder::new(); + let mut decoder = ruzstd::decoding::FrameDecoder::new(); decoder.reset(&mut data).unwrap(); let mut result = vec![]; while !decoder.is_finished() || decoder.can_collect() > 0 { decoder .decode_blocks( &mut data, - ruzstd::decoding::frame_decoder::BlockDecodingStrategy::UptoBytes(1024 * 1024), + ruzstd::decoding::BlockDecodingStrategy::UptoBytes(1024 * 1024), ) .unwrap(); decoder.collect_to_writer(&mut result).unwrap(); @@ -35,10 +35,10 @@ fn encode_ruzstd_uncompressed(data: &mut dyn std::io::Read) -> Vec { let mut input = Vec::new(); let mut output = Vec::new(); data.read_to_end(&mut input).unwrap(); - let mut compressor = ruzstd::encoding::frame_compressor::FrameCompressor::new( + let mut compressor = ruzstd::encoding::FrameCompressor::new( input.as_slice(), &mut output, - ruzstd::encoding::frame_compressor::CompressionLevel::Uncompressed, + ruzstd::encoding::CompressionLevel::Uncompressed, ); compressor.compress(); output @@ -48,10 +48,10 @@ fn encode_ruzstd_compressed(data: &mut dyn std::io::Read) -> Vec { let mut input = Vec::new(); let mut output = Vec::new(); data.read_to_end(&mut input).unwrap(); - let mut compressor = ruzstd::encoding::frame_compressor::FrameCompressor::new( + let mut compressor = ruzstd::encoding::FrameCompressor::new( input.as_slice(), &mut output, - ruzstd::encoding::frame_compressor::CompressionLevel::Fastest, + ruzstd::encoding::CompressionLevel::Fastest, ); compressor.compress(); output diff --git a/src/bin/zstd.rs b/src/bin/zstd.rs index 13a6311..3a5321a 100644 --- a/src/bin/zstd.rs +++ b/src/bin/zstd.rs @@ -9,8 +9,8 @@ use std::time::Instant; use ruzstd::decoding::errors::FrameDecoderError; use ruzstd::decoding::errors::ReadFrameHeaderError; -use ruzstd::encoding::frame_compressor::CompressionLevel; -use ruzstd::encoding::frame_compressor::FrameCompressor; +use ruzstd::encoding::CompressionLevel; +use ruzstd::encoding::FrameCompressor; struct StateTracker { bytes_used: u64, @@ -41,7 +41,7 @@ fn decompress(flags: &[String], file_paths: &[String]) { return; } - let mut frame_dec = ruzstd::decoding::frame_decoder::FrameDecoder::new(); + let mut frame_dec = ruzstd::decoding::FrameDecoder::new(); for path in file_paths { eprintln!("File: {}", path); @@ -81,9 +81,7 @@ fn decompress(flags: &[String], file_paths: &[String]) { frame_dec .decode_blocks( &mut f, - ruzstd::decoding::frame_decoder::BlockDecodingStrategy::UptoBytes( - batch_size, - ), + ruzstd::decoding::BlockDecodingStrategy::UptoBytes(batch_size), ) .unwrap(); diff --git a/src/bin/zstd_stream.rs b/src/bin/zstd_stream.rs index b25fe82..609530e 100644 --- a/src/bin/zstd_stream.rs +++ b/src/bin/zstd_stream.rs @@ -30,8 +30,7 @@ fn main() { let f = File::open(path).unwrap(); let mut buf_read = std::io::BufReader::new(f); - let mut decoder = - ruzstd::decoding::streaming_decoder::StreamingDecoder::new(&mut buf_read).unwrap(); + let mut decoder = ruzstd::decoding::StreamingDecoder::new(&mut buf_read).unwrap(); let mut buf = [0u8; 1024 * 1024]; let mut stdout = std::io::stdout(); while !decoder.decoder.is_finished() || decoder.decoder.can_collect() > 0 { diff --git a/src/decoding/frame_decoder.rs b/src/decoding/frame_decoder.rs index 103199a..1a0675b 100644 --- a/src/decoding/frame_decoder.rs +++ b/src/decoding/frame_decoder.rs @@ -21,11 +21,11 @@ use core::convert::TryInto; /// It reads bytes as needed from a provided source and can be read from to collect partial results. /// /// If you want to just read the whole frame with an `io::Read` without having to deal with manually calling [FrameDecoder::decode_blocks] -/// you can use the provided [crate::decoding::streaming_decoder::StreamingDecoder] wich wraps this FrameDecoder. +/// you can use the provided [crate::decoding::StreamingDecoder] wich wraps this FrameDecoder. /// /// Workflow is as follows: /// ``` -/// use ruzstd::decoding::frame_decoder::BlockDecodingStrategy; +/// use ruzstd::decoding::BlockDecodingStrategy; /// /// # #[cfg(feature = "std")] /// use std::io::{Read, Write}; @@ -36,7 +36,7 @@ use core::convert::TryInto; /// /// fn decode_this(mut file: impl Read) { /// //Create a new decoder -/// let mut frame_dec = ruzstd::decoding::frame_decoder::FrameDecoder::new(); +/// let mut frame_dec = ruzstd::decoding::FrameDecoder::new(); /// let mut result = Vec::new(); /// /// // Use reset or init to make the decoder ready to decode the frame from the io::Read diff --git a/src/decoding/mod.rs b/src/decoding/mod.rs index 2ac4f36..2461fef 100644 --- a/src/decoding/mod.rs +++ b/src/decoding/mod.rs @@ -1,8 +1,11 @@ //! Structures and utilities used for decoding zstd formatted data pub mod errors; -pub mod frame_decoder; -pub mod streaming_decoder; +mod frame_decoder; +mod streaming_decoder; + +pub use frame_decoder::{BlockDecodingStrategy, FrameDecoder}; +pub use streaming_decoder::StreamingDecoder; pub(crate) mod bit_reader; pub(crate) mod bit_reader_reverse; diff --git a/src/decoding/streaming_decoder.rs b/src/decoding/streaming_decoder.rs index 896dd58..cc3fbf2 100644 --- a/src/decoding/streaming_decoder.rs +++ b/src/decoding/streaming_decoder.rs @@ -3,7 +3,7 @@ use core::borrow::BorrowMut; use crate::decoding::errors::FrameDecoderError; -use crate::decoding::frame_decoder::{BlockDecodingStrategy, FrameDecoder}; +use crate::decoding::{BlockDecodingStrategy, FrameDecoder}; use crate::io::{Error, ErrorKind, Read}; /// High level Zstandard frame decoder that can be used to decompress a given Zstandard frame. @@ -31,7 +31,7 @@ use crate::io::{Error, ErrorKind, Read}; /// { /// use std::fs::File; /// use std::io::Read; -/// use ruzstd::decoding::streaming_decoder::StreamingDecoder; +/// use ruzstd::decoding::StreamingDecoder; /// /// // Read a Zstandard archive from the filesystem then decompress it into a vec. /// let mut f: File = todo!("Read a .zstd archive from somewhere"); diff --git a/src/encoding/frame_compressor.rs b/src/encoding/frame_compressor.rs index fc11795..fd7173c 100644 --- a/src/encoding/frame_compressor.rs +++ b/src/encoding/frame_compressor.rs @@ -45,7 +45,7 @@ pub enum CompressionLevel { /// /// # Examples /// ``` -/// use ruzstd::encoding::frame_compressor::{FrameCompressor, CompressionLevel}; +/// use ruzstd::encoding::{FrameCompressor, CompressionLevel}; /// let mock_data: &[_] = &[0x1, 0x2, 0x3, 0x4]; /// let mut output = std::vec::Vec::new(); /// // Initialize a compressor. @@ -190,7 +190,7 @@ mod tests { use alloc::vec; use super::FrameCompressor; - use crate::decoding::{frame::MAGIC_NUM, frame_decoder::FrameDecoder}; + use crate::decoding::{frame::MAGIC_NUM, FrameDecoder}; use alloc::vec::Vec; #[test] @@ -286,24 +286,21 @@ mod tests { fn fuzz_targets() { use std::io::Read; fn decode_ruzstd(data: &mut dyn std::io::Read) -> Vec { - let mut decoder = - crate::decoding::streaming_decoder::StreamingDecoder::new(data).unwrap(); + let mut decoder = crate::decoding::StreamingDecoder::new(data).unwrap(); let mut result: Vec = Vec::new(); decoder.read_to_end(&mut result).expect("Decoding failed"); result } fn decode_ruzstd_writer(mut data: impl Read) -> Vec { - let mut decoder = crate::decoding::frame_decoder::FrameDecoder::new(); + let mut decoder = crate::decoding::FrameDecoder::new(); decoder.reset(&mut data).unwrap(); let mut result = vec![]; while !decoder.is_finished() || decoder.can_collect() > 0 { decoder .decode_blocks( &mut data, - crate::decoding::frame_decoder::BlockDecodingStrategy::UptoBytes( - 1024 * 1024, - ), + crate::decoding::BlockDecodingStrategy::UptoBytes(1024 * 1024), ) .unwrap(); decoder.collect_to_writer(&mut result).unwrap(); diff --git a/src/encoding/mod.rs b/src/encoding/mod.rs index 90cd3f1..133fadb 100644 --- a/src/encoding/mod.rs +++ b/src/encoding/mod.rs @@ -7,16 +7,16 @@ pub(crate) mod frame_header; pub(crate) mod match_generator; pub(crate) mod util; -pub mod frame_compressor; +mod frame_compressor; +pub use frame_compressor::{CompressionLevel, FrameCompressor}; use crate::io::{Read, Write}; use alloc::vec::Vec; -use frame_compressor::{CompressionLevel, FrameCompressor}; use match_generator::Sequence; /// Convenience function to compress some source into a target without reusing any resources of the compressor /// ```rust -/// use ruzstd::encoding::{compress, frame_compressor::CompressionLevel}; +/// use ruzstd::encoding::{compress, CompressionLevel}; /// let data: &[u8] = &[0,0,0,0,0,0,0,0,0,0,0,0]; /// let mut target = Vec::new(); /// compress(data, &mut target, CompressionLevel::Fastest); @@ -28,7 +28,7 @@ pub fn compress(source: R, target: W, level: CompressionLevel /// Convenience function to compress some source into a target without reusing any resources of the compressor into a Vec /// ```rust -/// use ruzstd::encoding::{compress_to_vec, frame_compressor::CompressionLevel}; +/// use ruzstd::encoding::{compress_to_vec, CompressionLevel}; /// let data: &[u8] = &[0,0,0,0,0,0,0,0,0,0,0,0]; /// let compressed = compress_to_vec(data, CompressionLevel::Fastest); /// ``` diff --git a/src/lib.rs b/src/lib.rs index f7a9669..3f02b31 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -2,13 +2,13 @@ //! //! ## Decompression //! The [decoding] module contains the code for decompression. -//! Decompression can be achieved by using the [`decoding::streaming_decoder::StreamingDecoder`] -//! or the more low-level [`decoding::frame_decoder::FrameDecoder`] +//! Decompression can be achieved by using the [`decoding::StreamingDecoder`] +//! or the more low-level [`decoding::FrameDecoder`] //! //! ## Compression //! The [encoding] module contains the code for compression. //! Decompression can be achieved by using the [`encoding::compress`]/[`encoding::compress_to_vec`] -//! functions or the [`encoding::frame_compressor::FrameCompressor`] +//! functions or the [`encoding::FrameCompressor`] //! #![doc = include_str!("../Readme.md")] #![no_std] diff --git a/src/tests/decode_corpus.rs b/src/tests/decode_corpus.rs index b17ff6d..69844e4 100644 --- a/src/tests/decode_corpus.rs +++ b/src/tests/decode_corpus.rs @@ -1,7 +1,8 @@ #[test] fn test_decode_corpus_files() { extern crate std; - use crate::decoding::frame_decoder; + use crate::decoding::BlockDecodingStrategy; + use crate::decoding::FrameDecoder; use alloc::borrow::ToOwned; use alloc::string::{String, ToString}; use alloc::vec::Vec; @@ -31,7 +32,7 @@ fn test_decode_corpus_files() { Ok(entry) => entry.path().to_str().unwrap().to_owned(), }); - let mut frame_dec = frame_decoder::FrameDecoder::new(); + let mut frame_dec = FrameDecoder::new(); for file in files { let f = file.unwrap(); @@ -51,7 +52,7 @@ fn test_decode_corpus_files() { let start_time = std::time::Instant::now(); /////DECODING frame_dec - .decode_blocks(&mut content, frame_decoder::BlockDecodingStrategy::All) + .decode_blocks(&mut content, BlockDecodingStrategy::All) .unwrap(); let result = frame_dec.collect().unwrap(); let end_time = start_time.elapsed(); diff --git a/src/tests/dict_test.rs b/src/tests/dict_test.rs index f46de53..516b178 100644 --- a/src/tests/dict_test.rs +++ b/src/tests/dict_test.rs @@ -77,7 +77,8 @@ fn test_dict_parsing() { #[test] fn test_dict_decoding() { extern crate std; - use crate::decoding::frame_decoder; + use crate::decoding::BlockDecodingStrategy; + use crate::decoding::FrameDecoder; use alloc::borrow::ToOwned; use alloc::string::{String, ToString}; use alloc::vec::Vec; @@ -104,7 +105,7 @@ fn test_dict_decoding() { Ok(entry) => entry.path().to_str().unwrap().to_owned(), }); - let mut frame_dec = frame_decoder::FrameDecoder::new(); + let mut frame_dec = FrameDecoder::new(); let dict = crate::decoding::dictionary::Dictionary::decode_dict(&dict).unwrap(); frame_dec.add_dict(dict).unwrap(); @@ -126,7 +127,7 @@ fn test_dict_decoding() { let start_time = std::time::Instant::now(); /////DECODING frame_dec - .decode_blocks(&mut content, frame_decoder::BlockDecodingStrategy::All) + .decode_blocks(&mut content, BlockDecodingStrategy::All) .unwrap(); let result = frame_dec.collect().unwrap(); let end_time = start_time.elapsed(); diff --git a/src/tests/encode_corpus.rs b/src/tests/encode_corpus.rs index 1c9de57..86baf40 100644 --- a/src/tests/encode_corpus.rs +++ b/src/tests/encode_corpus.rs @@ -1,7 +1,7 @@ #[test] fn test_encode_corpus_files_uncompressed_our_decompressor() { extern crate std; - use crate::encoding::frame_compressor::FrameCompressor; + use crate::encoding::FrameCompressor; use alloc::borrow::ToOwned; use alloc::vec::Vec; use std::ffi::OsStr; @@ -34,13 +34,12 @@ fn test_encode_corpus_files_uncompressed_our_decompressor() { let mut compressor = FrameCompressor::new( input.as_slice(), &mut compressed_file, - crate::encoding::frame_compressor::CompressionLevel::Fastest, + crate::encoding::CompressionLevel::Fastest, ); compressor.compress(); let mut decompressed_output = Vec::new(); let mut decoder = - crate::decoding::streaming_decoder::StreamingDecoder::new(compressed_file.as_slice()) - .unwrap(); + crate::decoding::StreamingDecoder::new(compressed_file.as_slice()).unwrap(); decoder.read_to_end(&mut decompressed_output).unwrap(); if input != decompressed_output { @@ -59,7 +58,7 @@ fn test_encode_corpus_files_uncompressed_our_decompressor() { #[test] fn test_encode_corpus_files_uncompressed_original_decompressor() { extern crate std; - use crate::encoding::frame_compressor::FrameCompressor; + use crate::encoding::FrameCompressor; use alloc::borrow::ToOwned; use alloc::format; use alloc::vec::Vec; @@ -92,7 +91,7 @@ fn test_encode_corpus_files_uncompressed_original_decompressor() { let mut compressor = FrameCompressor::new( input.as_slice(), &mut compressed_file, - crate::encoding::frame_compressor::CompressionLevel::Fastest, + crate::encoding::CompressionLevel::Fastest, ); compressor.compress(); let mut decompressed_output = Vec::new(); @@ -123,7 +122,7 @@ fn test_encode_corpus_files_uncompressed_original_decompressor() { #[test] fn test_encode_corpus_files_compressed_our_decompressor() { extern crate std; - use crate::encoding::frame_compressor::FrameCompressor; + use crate::encoding::FrameCompressor; use alloc::borrow::ToOwned; use alloc::vec::Vec; use std::ffi::OsStr; @@ -155,13 +154,12 @@ fn test_encode_corpus_files_compressed_our_decompressor() { let mut compressor = FrameCompressor::new( input.as_slice(), &mut compressed_file, - crate::encoding::frame_compressor::CompressionLevel::Fastest, + crate::encoding::CompressionLevel::Fastest, ); compressor.compress(); let mut decompressed_output = Vec::new(); let mut decoder = - crate::decoding::streaming_decoder::StreamingDecoder::new(compressed_file.as_slice()) - .unwrap(); + crate::decoding::StreamingDecoder::new(compressed_file.as_slice()).unwrap(); decoder.read_to_end(&mut decompressed_output).unwrap(); if input != decompressed_output { @@ -180,7 +178,7 @@ fn test_encode_corpus_files_compressed_our_decompressor() { #[test] fn test_encode_corpus_files_compressed_original_decompressor() { extern crate std; - use crate::encoding::frame_compressor::FrameCompressor; + use crate::encoding::FrameCompressor; use alloc::borrow::ToOwned; use alloc::format; use alloc::vec::Vec; @@ -213,7 +211,7 @@ fn test_encode_corpus_files_compressed_original_decompressor() { let mut compressor = FrameCompressor::new( input.as_slice(), &mut compressed_file, - crate::encoding::frame_compressor::CompressionLevel::Fastest, + crate::encoding::CompressionLevel::Fastest, ); compressor.compress(); let mut decompressed_output = Vec::new(); diff --git a/src/tests/fuzz_regressions.rs b/src/tests/fuzz_regressions.rs index 088b09e..a9fa5c9 100644 --- a/src/tests/fuzz_regressions.rs +++ b/src/tests/fuzz_regressions.rs @@ -1,12 +1,13 @@ #[test] fn test_all_artifacts() { extern crate std; - use crate::decoding::frame_decoder; + use crate::decoding::BlockDecodingStrategy; + use crate::decoding::FrameDecoder; use std::borrow::ToOwned; use std::fs; use std::fs::File; - let mut frame_dec = frame_decoder::FrameDecoder::new(); + let mut frame_dec = FrameDecoder::new(); for file in fs::read_dir("./fuzz/artifacts/decode").unwrap() { let file_name = file.unwrap().path(); @@ -19,8 +20,8 @@ fn test_all_artifacts() { let mut f = File::open(file_name.clone()).unwrap(); /* ignore errors. It just should never panic on invalid input */ - let _: Result<_, _> = frame_dec.reset(&mut f).and_then(|()| { - frame_dec.decode_blocks(&mut f, frame_decoder::BlockDecodingStrategy::All) - }); + let _: Result<_, _> = frame_dec + .reset(&mut f) + .and_then(|()| frame_dec.decode_blocks(&mut f, BlockDecodingStrategy::All)); } } diff --git a/src/tests/mod.rs b/src/tests/mod.rs index 24695df..52fda6d 100644 --- a/src/tests/mod.rs +++ b/src/tests/mod.rs @@ -37,7 +37,7 @@ fn assure_error_impl() { fn assure_decoder_send_sync() { // not a real test just there to throw an compiler error if FrameDecoder is Send + Sync - use crate::decoding::frame_decoder::FrameDecoder; + use crate::decoding::FrameDecoder; let decoder = FrameDecoder::new(); std::thread::spawn(move || { drop(decoder); @@ -102,7 +102,8 @@ fn test_block_header_reading() { #[test] fn test_frame_decoder() { - use crate::decoding::frame_decoder; + use crate::decoding::BlockDecodingStrategy; + use crate::decoding::FrameDecoder; use std::fs; let mut content = fs::File::open("./decodecorpus_files/z000088.zst").unwrap(); @@ -118,20 +119,20 @@ fn test_frame_decoder() { } let mut _null_target = NullWriter(()); - let mut frame_dec = frame_decoder::FrameDecoder::new(); + let mut frame_dec = FrameDecoder::new(); frame_dec.reset(&mut content).unwrap(); frame_dec - .decode_blocks(&mut content, frame_decoder::BlockDecodingStrategy::All) + .decode_blocks(&mut content, BlockDecodingStrategy::All) .unwrap(); } #[test] fn test_decode_from_to() { - use crate::decoding::frame_decoder; + use crate::decoding::FrameDecoder; use std::fs::File; use std::io::Read; let f = File::open("./decodecorpus_files/z000088.zst").unwrap(); - let mut frame_dec = frame_decoder::FrameDecoder::new(); + let mut frame_dec = FrameDecoder::new(); let content: Vec = f.bytes().map(|x| x.unwrap()).collect(); @@ -229,7 +230,8 @@ fn test_decode_from_to() { #[test] fn test_specific_file() { - use crate::decoding::frame_decoder; + use crate::decoding::BlockDecodingStrategy; + use crate::decoding::FrameDecoder; use std::fs; use std::io::Read; @@ -247,10 +249,10 @@ fn test_specific_file() { } let mut _null_target = NullWriter(()); - let mut frame_dec = frame_decoder::FrameDecoder::new(); + let mut frame_dec = FrameDecoder::new(); frame_dec.reset(&mut content).unwrap(); frame_dec - .decode_blocks(&mut content, frame_decoder::BlockDecodingStrategy::All) + .decode_blocks(&mut content, BlockDecodingStrategy::All) .unwrap(); let result = frame_dec.collect().unwrap(); @@ -294,8 +296,7 @@ fn test_streaming() { use std::io::Read; let mut content = fs::File::open("./decodecorpus_files/z000088.zst").unwrap(); - let mut stream = - crate::decoding::streaming_decoder::StreamingDecoder::new(&mut content).unwrap(); + let mut stream = crate::decoding::StreamingDecoder::new(&mut content).unwrap(); let mut result = Vec::new(); Read::read_to_end(&mut stream, &mut result).unwrap(); @@ -333,7 +334,7 @@ fn test_streaming() { // Test resetting to a new file while keeping the old decoder let mut content = fs::File::open("./decodecorpus_files/z000068.zst").unwrap(); - let mut stream = crate::decoding::streaming_decoder::StreamingDecoder::new_with_decoder( + let mut stream = crate::decoding::StreamingDecoder::new_with_decoder( &mut content, stream.into_frame_decoder(), ) @@ -377,7 +378,7 @@ fn test_streaming() { #[test] fn test_incremental_read() { - use crate::decoding::frame_decoder::FrameDecoder; + use crate::decoding::FrameDecoder; let mut unread_compressed_content = include_bytes!("../../decodecorpus_files/abc.txt.zst").as_slice(); @@ -406,8 +407,7 @@ fn test_streaming_no_std() { let content = include_bytes!("../../decodecorpus_files/z000088.zst"); let mut content = content.as_slice(); - let mut stream = - crate::decoding::streaming_decoder::StreamingDecoder::new(&mut content).unwrap(); + let mut stream = crate::decoding::StreamingDecoder::new(&mut content).unwrap(); let original = include_bytes!("../../decodecorpus_files/z000088"); let mut result = vec![0; original.len()]; @@ -444,7 +444,7 @@ fn test_streaming_no_std() { let content = include_bytes!("../../decodecorpus_files/z000068.zst"); let mut content = content.as_slice(); - let mut stream = crate::decoding::streaming_decoder::StreamingDecoder::new_with_decoder( + let mut stream = crate::decoding::StreamingDecoder::new_with_decoder( &mut content, stream.into_frame_decoder(), ) @@ -487,7 +487,7 @@ fn test_streaming_no_std() { #[test] fn test_decode_all() { use crate::decoding::errors::FrameDecoderError; - use crate::decoding::frame_decoder::FrameDecoder; + use crate::decoding::FrameDecoder; let skip_frame = |input: &mut Vec, length: usize| { input.extend_from_slice(&0x184D2A50u32.to_le_bytes());