(&mut self, py: Python<'_>)
| 446 | |
| 447 | #[getter] |
| 448 | fn text(&mut self, py: Python<'_>) -> PyResult<String> { |
| 449 | if let Some(cached_text) = &self.text { |
| 450 | return Ok(cached_text.clone()); |
| 451 | } |
| 452 | |
| 453 | let content_bytes = self.read(py)?; |
| 454 | let decoder = encoding_from_whatwg_label(&self.encoding); |
| 455 | let decoded_text = impit::utils::decode(&content_bytes, decoder); |
| 456 | |
| 457 | self.text = Some(decoded_text.clone()); |
| 458 | Ok(decoded_text) |
| 459 | } |
| 460 | |
| 461 | fn json(&mut self, py: Python<'_>) -> PyResult<Py<PyAny>> { |
| 462 | let text = self.text(py)?; |