MCPcopy Index your code
hub / github.com/RustPython/RustPython / flush

Method flush

crates/stdlib/src/bz2.rs:177–190  ·  view source on GitHub ↗
(&self, vm: &VirtualMachine)

Source from the content-addressed store, hash-verified

175
176 #[pymethod]
177 fn flush(&self, vm: &VirtualMachine) -> PyResult<PyBytesRef> {
178 let mut state = self.state.lock();
179 if state.flushed {
180 return Err(vm.new_value_error("Repeated call to flush()"));
181 }
182
183 // let CompressorState { flushed, encoder } = &mut *state;
184 let CompressorState { encoder, .. } = &mut *state;
185
186 // TODO: handle Err
187 let out = encoder.take().unwrap().finish().unwrap();
188 state.flushed = true;
189 Ok(vm.ctx.new_bytes(out.to_vec()))
190 }
191
192 #[pymethod(name = "__reduce__")]
193 fn reduce(&self, vm: &VirtualMachine) -> PyResult<()> {

Callers 5

compressFunction · 0.95
testCompressMethod · 0.95
testCompressChunks10Method · 0.95
testCompress4GMethod · 0.95

Calls 7

to_vecMethod · 0.80
ErrClass · 0.50
lockMethod · 0.45
unwrapMethod · 0.45
finishMethod · 0.45
takeMethod · 0.45
new_bytesMethod · 0.45

Tested by 4

testCompressMethod · 0.76
testCompressChunks10Method · 0.76
testCompress4GMethod · 0.76