an efficient binary archive format
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

close Writer on drop

zach 37292c88 2a53a4c7

+13 -5
-2
README.md
··· 1 1 # bindle-file 2 2 3 3 `bindle` is a general purpose, binary archive format designed for efficient reads and writes. 4 - 5 -
+13 -3
src/lib.rs
··· 137 137 pub(crate) uncompressed_size: u64, 138 138 } 139 139 140 + impl<'a> Drop for Writer<'a> { 141 + fn drop(&mut self) { 142 + let _ = self.close_drop(); 143 + } 144 + } 145 + 140 146 impl<'a> std::io::Write for Writer<'a> { 141 147 fn write(&mut self, buf: &[u8]) -> io::Result<usize> { 142 148 self.write_chunk(buf)?; ··· 161 167 Ok(()) 162 168 } 163 169 164 - pub fn close(self) -> io::Result<()> { 165 - let compression_type = if let Some(encoder) = self.encoder { 170 + fn close_drop(&mut self) -> io::Result<()> { 171 + let compression_type = if let Some(encoder) = self.encoder.take() { 166 172 encoder.finish()?; 167 173 1 168 174 } else { ··· 189 195 ..Default::default() 190 196 }; 191 197 192 - self.bindle.index.insert(self.name, entry); 198 + self.bindle.index.insert(self.name.clone(), entry); 193 199 Ok(()) 200 + } 201 + 202 + pub fn close(mut self) -> io::Result<()> { 203 + self.close_drop() 194 204 } 195 205 } 196 206