| 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 { |