diff --git a/src/write/compression.rs b/src/write/compression.rs index a58187fa6..7ea00cc8f 100644 --- a/src/write/compression.rs +++ b/src/write/compression.rs @@ -107,11 +107,6 @@ pub struct Compressor>> { } impl>> Compressor { - /// Creates a new [`Compressor`] - pub fn new_from_vec(iter: I, compression: CompressionOptions, buffer: Vec) -> Self { - Self::new(iter, compression, buffer) - } - /// Creates a new [`Compressor`] pub fn new(iter: I, compression: CompressionOptions, buffer: Vec) -> Self { Self { @@ -121,6 +116,22 @@ impl>> Compressor { current: None, } } + + /// Creates a new [`Compressor`] (same as `new`) + pub fn new_from_vec(iter: I, compression: CompressionOptions, buffer: Vec) -> Self { + Self::new(iter, compression, buffer) + } + + /// Deconstructs itself into its iterator and scratch buffer. + pub fn into_inner(mut self) -> (I, Vec) { + let mut buffer = if let Some(page) = self.current.as_mut() { + std::mem::take(page.buffer()) + } else { + std::mem::take(&mut self.buffer) + }; + buffer.clear(); + (self.iter, buffer) + } } impl>> FallibleStreamingIterator for Compressor {