From 43bcb62d987d2734111297b907ce2337e4bc5ceb Mon Sep 17 00:00:00 2001 From: Brian Langenberger Date: Thu, 17 Dec 2020 10:31:29 -0600 Subject: [PATCH] Add trivial flush method to BitWriter Since it's specific to anything that implements Write, it's attached to BitWriter rather than the BitWrite trait. --- src/write.rs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/write.rs b/src/write.rs index a0e32fe..47ac29b 100644 --- a/src/write.rs +++ b/src/write.rs @@ -184,6 +184,17 @@ impl BitWriter { pub fn into_unwritten(self) -> (u32, u8) { (self.bitqueue.len(), self.bitqueue.value()) } + + /// Flushes output stream to disk, if necessary. + /// Any partial bytes are not flushed. + /// + /// # Errors + /// + /// Passes along any errors from the underlying stream. + #[inline(always)] + pub fn flush(&mut self) -> io::Result<()> { + self.writer.flush() + } } /// A trait for anything that can write a variable number of