lib.rs 556 B

12345678910111213141516171819202122232425
  1. use wasm_bindgen::prelude::*;
  2. use fflate;
  3. #[wasm_bindgen]
  4. pub struct Inflate {
  5. buf: &'static Vec<u8>,
  6. inflator: fflate::Inflate<'static>
  7. }
  8. #[wasm_bindgen]
  9. impl Inflate {
  10. #[wasm_bindgen(constructor)]
  11. pub fn new() -> Inflate {
  12. unsafe {
  13. static mut buf: Vec<u8> = Vec::new();
  14. Inflate {
  15. buf: &buf,
  16. inflator: fflate::Inflate::new(&mut buf)
  17. }
  18. }
  19. }
  20. pub fn push(&mut self, dat: &[u8], last: bool) -> Result<> {
  21. self.inflator.write_all(dat);
  22. }
  23. }