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

Method new

crates/stdlib/src/zlib.rs:121–134  ·  view source on GitHub ↗
(wbits: i8, vm: &VirtualMachine)

Source from the content-addressed store, hash-verified

119
120 impl InitOptions {
121 fn new(wbits: i8, vm: &VirtualMachine) -> PyResult<Self> {
122 let header = wbits > 0;
123 let wbits = wbits.unsigned_abs();
124 match wbits {
125 // TODO: wbits = 0 should be a valid option:
126 // > windowBits can also be zero to request that inflate use the window size in
127 // > the zlib header of the compressed stream.
128 // but flate2 doesn't expose it
129 // 0 => ...
130 9..=15 => Ok(Self::Standard { header, wbits }),
131 25..=31 => Ok(Self::Gzip { wbits: wbits - 16 }),
132 _ => Err(vm.new_value_error("Invalid initialization option")),
133 }
134 }
135
136 fn decompress(self) -> Decompress {
137 match self {

Callers

nothing calls this directly

Calls 4

newFunction · 0.85
SelfFunction · 0.85
ErrClass · 0.50
SomeClass · 0.50

Tested by

no test coverage detected