diff --git a/Cargo.lock b/Cargo.lock index ecd8a95..4ddb170 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -138,12 +138,6 @@ dependencies = [ "windows-targets", ] -[[package]] -name = "circular" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b0fc239e0f6cb375d2402d48afb92f76f5404fd1df208a41930ec81eda078bea" - [[package]] name = "clap" version = "4.4.18" @@ -512,6 +506,12 @@ version = "1.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" +[[package]] +name = "oval" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5a3d5e98a4755181412036942c50378249d94aca605a3b024cda24c67cc1a1b8" + [[package]] name = "overload" version = "0.1.1" @@ -635,7 +635,6 @@ dependencies = [ "cfg-if", "chardetng", "chrono", - "circular", "crc32fast", "deflate64", "encoding_rs", @@ -644,6 +643,7 @@ dependencies = [ "nom", "num_enum", "oem_cp", + "oval", "positioned-io", "pretty-hex", "thiserror", diff --git a/crates/rc-zip/Cargo.toml b/crates/rc-zip/Cargo.toml index 6b7c35c..30d5dc2 100644 --- a/crates/rc-zip/Cargo.toml +++ b/crates/rc-zip/Cargo.toml @@ -14,7 +14,7 @@ categories = ["compression"] [dependencies] nom = "7.1.3" pretty-hex = "0.4.1" -circular = "0.3.0" +oval = "1.0.0" chrono = "0.4.33" encoding_rs = "0.8.33" crc32fast = "1.3.2" diff --git a/crates/rc-zip/src/reader/buffer.rs b/crates/rc-zip/src/reader/buffer.rs index d8db83f..7e2fda9 100644 --- a/crates/rc-zip/src/reader/buffer.rs +++ b/crates/rc-zip/src/reader/buffer.rs @@ -2,10 +2,10 @@ use std::io::Read; use tracing::trace; -/// A wrapper around [circular::Buffer] that keeps track of how many bytes we've read since +/// A wrapper around [oval::Buffer] that keeps track of how many bytes we've read since /// initialization or the last reset. pub(crate) struct Buffer { - pub(crate) buffer: circular::Buffer, + pub(crate) buffer: oval::Buffer, pub(crate) read_bytes: u64, } @@ -13,7 +13,7 @@ impl Buffer { /// creates a new buffer with the specified capacity pub(crate) fn with_capacity(size: usize) -> Self { Self { - buffer: circular::Buffer::with_capacity(size), + buffer: oval::Buffer::with_capacity(size), read_bytes: 0, } } diff --git a/crates/rc-zip/src/reader/sync/decoder.rs b/crates/rc-zip/src/reader/sync/decoder.rs index 2f51465..f2f70cc 100644 --- a/crates/rc-zip/src/reader/sync/decoder.rs +++ b/crates/rc-zip/src/reader/sync/decoder.rs @@ -1,5 +1,7 @@ use std::{cmp, io}; +use oval::Buffer; + pub trait Decoder: io::Read where R: io::Read, @@ -50,23 +52,23 @@ where } } -/// Only allows reading a fixed number of bytes from a [circular::Buffer], +/// Only allows reading a fixed number of bytes from a [oval::Buffer], /// allowing to move the inner reader out afterwards. pub struct LimitedReader { remaining: u64, - inner: circular::Buffer, + inner: Buffer, } impl LimitedReader { - pub fn new(inner: circular::Buffer, remaining: u64) -> Self { + pub fn new(inner: Buffer, remaining: u64) -> Self { Self { inner, remaining } } - pub fn into_inner(self) -> circular::Buffer { + pub fn into_inner(self) -> Buffer { self.inner } - pub fn get_mut(&mut self) -> &mut circular::Buffer { + pub fn get_mut(&mut self) -> &mut Buffer { &mut self.inner } } diff --git a/crates/rc-zip/src/reader/sync/entry_reader/mod.rs b/crates/rc-zip/src/reader/sync/entry_reader/mod.rs index 6dffe23..39b88ef 100644 --- a/crates/rc-zip/src/reader/sync/entry_reader/mod.rs +++ b/crates/rc-zip/src/reader/sync/entry_reader/mod.rs @@ -18,6 +18,7 @@ mod deflate64_dec; use cfg_if::cfg_if; use nom::Offset; +use oval::Buffer; use std::io; use tracing::trace; @@ -28,7 +29,7 @@ struct EntryReadMetrics { enum State { ReadLocalHeader { - buffer: circular::Buffer, + buffer: Buffer, }, ReadData { hasher: crc32fast::Hasher, @@ -39,7 +40,7 @@ enum State { ReadDataDescriptor { metrics: EntryReadMetrics, header: LocalFileHeaderRecord, - buffer: circular::Buffer, + buffer: Buffer, }, Validate { metrics: EntryReadMetrics, @@ -256,7 +257,7 @@ where rd: EOFNormalizer::new(get_reader(entry.header_offset)), eof: false, state: State::ReadLocalHeader { - buffer: circular::Buffer::with_capacity(Self::DEFAULT_BUFFER_SIZE), + buffer: Buffer::with_capacity(Self::DEFAULT_BUFFER_SIZE), }, method: entry.method(), inner: entry.inner,