(&mut self, ctx: &Ctx<'_>)
| 192 | } |
| 193 | |
| 194 | fn flush(&mut self, ctx: &Ctx<'_>) -> Result<String> { |
| 195 | if matches!(self.encoder, Encoder::Utf16le) && self.buffered_bytes % 2 == 1 { |
| 196 | // Ignore a single trailing byte, like the JS decoder does. |
| 197 | self.missing_bytes -= 1; |
| 198 | self.buffered_bytes -= 1; |
| 199 | } |
| 200 | |
| 201 | if self.buffered_bytes == 0 { |
| 202 | return Ok(String::new()); |
| 203 | } |
| 204 | |
| 205 | let res = self.make_string(ctx, &self.buffer); |
| 206 | |
| 207 | self.missing_bytes = 0; |
| 208 | self.buffered_bytes = 0; |
| 209 | self.buffer.clear(); |
| 210 | |
| 211 | res |
| 212 | } |
| 213 | } |
| 214 | |
| 215 | #[rquickjs::methods(rename_all = "camelCase")] |
no test coverage detected