(&mut self, mode: C::Flush, vm: &VirtualMachine)
| 246 | } |
| 247 | |
| 248 | pub fn flush(&mut self, mode: C::Flush, vm: &VirtualMachine) -> PyResult<Vec<u8>> { |
| 249 | let mut buf = Vec::new(); |
| 250 | let compressor = self.get_compressor(vm)?; |
| 251 | |
| 252 | let status = loop { |
| 253 | if buf.len() == buf.capacity() { |
| 254 | buf.reserve(C::DEF_BUF_SIZE); |
| 255 | } |
| 256 | let status = compressor.compress_vec(&[], &mut buf, mode, vm)?; |
| 257 | if buf.len() != buf.capacity() { |
| 258 | break status; |
| 259 | } |
| 260 | }; |
| 261 | |
| 262 | if status.to_usize() == C::Status::EOF.to_usize() { |
| 263 | if mode.to_usize() == C::Flush::FINISH.to_usize() { |
| 264 | self.compressor = None; |
| 265 | } else { |
| 266 | return Err(C::new_error("unexpected eof", vm)); |
| 267 | } |
| 268 | } |
| 269 | |
| 270 | buf.shrink_to_fit(); |
| 271 | Ok(buf) |
| 272 | } |
| 273 | } |
| 274 | |
| 275 | #[derive(Debug)] |
nothing calls this directly
no test coverage detected