| 1 | use superrust-analyzer cargo lzzzz 2.0.0 lz4f/stream/decomp/::BufReadDecompressorrust-analyzer cargo lzzzz 2.0.0 lz4f/stream/decomp/bufread/BufReadDecompressor#; |
| 2 | use craterust-analyzer cargo lzzzz 2.0.0 crate/::lz4frust-analyzer cargo lzzzz 2.0.0 lz4f/::{FrameInforust-analyzer cargo lzzzz 2.0.0 lz4f/frame_info/FrameInfo#, Resultrust-analyzer cargo lzzzz 2.0.0 lz4f/error/Result#}; |
| 3 | use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::{ |
| 4 | borrowrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc borrow/::Cowrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc borrow/Cow#, |
| 5 | fmtrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc fmt/, |
| 6 | iorust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/::{BufReaderrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/buffered/bufreader/BufReader#, Readrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/Read#}, |
| 7 | }; |
| 8 | |
| 9 | /// The [`Read`]-based streaming decompressor. |
| 10 | /// |
| 11 | /// # Example |
| 12 | /// |
| 13 | /// ``` |
| 14 | /// # use std::env; |
| 15 | /// # use std::path::Path; |
| 16 | /// # use lzzzz::{Error, Result}; |
| 17 | /// # use assert_fs::prelude::*; |
| 18 | /// # let tmp_dir = assert_fs::TempDir::new().unwrap().into_persistent(); |
| 19 | /// # env::set_current_dir(tmp_dir.path()).unwrap(); |
| 20 | /// # |
| 21 | /// # let mut buf = Vec::new(); |
| 22 | /// # lzzzz::lz4f::compress_to_vec(b"Hello world!", &mut buf, &Default::default())?; |
| 23 | /// # tmp_dir.child("foo.lz4").write_binary(&buf).unwrap(); |
| 24 | /// # |
| 25 | /// use lzzzz::lz4f::ReadDecompressor; |
| 26 | /// use std::{fs::File, io::prelude::*}; |
| 27 | /// |
| 28 | /// let mut f = File::open("foo.lz4")?; |
| 29 | /// let mut r = ReadDecompressor::new(&mut f)?; |
| 30 | /// |
| 31 | /// let mut buf = Vec::new(); |
| 32 | /// r.read_to_end(&mut buf)?; |
| 33 | /// # Ok::<(), std::io::Error>(()) |
| 34 | /// ``` |
| 35 | /// |
| 36 | /// [`Read`]: https://doc.rust-lang.org/std/io/trait.Read.html |
| 37 | pub struct ReadDecompressorrust-analyzer cargo lzzzz 2.0.0 lz4f/stream/decomp/read/ReadDecompressor#<'a, R: Readrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/Read#> { |
| 38 | innerrust-analyzer cargo lzzzz 2.0.0 lz4f/stream/decomp/read/ReadDecompressor#inner.: BufReadDecompressorrust-analyzer cargo lzzzz 2.0.0 lz4f/stream/decomp/bufread/BufReadDecompressor#<'a, BufReaderrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/buffered/bufreader/BufReader#<R>>, |
| 39 | } |
| 40 | |
| 41 | impl<R> fmtrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc fmt/::Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Debug# for ReadDecompressorrust-analyzer cargo lzzzz 2.0.0 lz4f/stream/decomp/read/ReadDecompressor#<'_, R> |
| 42 | where |
| 43 | R: Readrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/Read# + fmtrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc fmt/::Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Debug#, |
| 44 | { |
| 45 | fn fmtrust-analyzer cargo lzzzz 2.0.0 lz4f/stream/decomp/read/impl#[`ReadDecompressor<'_, R>`][Debug]fmt().(&self, fmt: &mut fmtrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc fmt/::Formatterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Formatter#<'_>) -> fmtrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc fmt/::Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Result# { |
| 46 | fmt.debug_structrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/impl#[`Formatter<'a>`]debug_struct().("ReadDecompressor") |
| 47 | .fieldrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/builders/impl#[`DebugStruct<'a, 'b>`]field().("reader", &self.innerrust-analyzer cargo lzzzz 2.0.0 lz4f/stream/decomp/read/ReadDecompressor#inner..innerrust-analyzer cargo lzzzz 2.0.0 lz4f/stream/decomp/bufread/BufReadDecompressor#inner..get_refrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/buffered/bufreader/impl#[`BufReader<R>`]get_ref().()) |
| 48 | .finishrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/builders/impl#[`DebugStruct<'a, 'b>`]finish().() |
| 49 | } |
| 50 | } |
| 51 | |
| 52 | impl<'a, R: Readrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/Read#> ReadDecompressorrust-analyzer cargo lzzzz 2.0.0 lz4f/stream/decomp/read/ReadDecompressor#<'a, R> { |
| 53 | /// Creates a new `ReadDecompressor<R>`. |
| 54 | pub fn newrust-analyzer cargo lzzzz 2.0.0 lz4f/stream/decomp/read/impl#[`ReadDecompressor<'a, R>`]new().(reader: R) -> Resultrust-analyzer cargo lzzzz 2.0.0 lz4f/error/Result#<Selfrust-analyzer cargo lzzzz 2.0.0 lz4f/stream/decomp/read/impl#[`ReadDecompressor<'a, R>`]> { |
| 55 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(Selfrust-analyzer cargo lzzzz 2.0.0 lz4f/stream/decomp/read/impl#[`ReadDecompressor<'a, R>`] { |
| 56 | innerrust-analyzer cargo lzzzz 2.0.0 lz4f/stream/decomp/read/ReadDecompressor#inner.: BufReadDecompressorrust-analyzer cargo lzzzz 2.0.0 lz4f/stream/decomp/bufread/BufReadDecompressor#::newrust-analyzer cargo lzzzz 2.0.0 lz4f/stream/decomp/bufread/impl#[`BufReadDecompressor<'a, R>`]new().(BufReaderrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/buffered/bufreader/BufReader#::newrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/buffered/bufreader/impl#[`BufReader<R>`]new().(reader))?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch()., |
| 57 | }) |
| 58 | } |
| 59 | |
| 60 | /// Sets the dictionary. |
| 61 | pub fn set_dictrust-analyzer cargo lzzzz 2.0.0 lz4f/stream/decomp/read/impl#[`ReadDecompressor<'a, R>`]set_dict().<D>(&mut self, dict: D) |
| 62 | where |
| 63 | D: Intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/Into#<Cowrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc borrow/Cow#<'a, [u8]>>, |
| 64 | { |
| 65 | self.innerrust-analyzer cargo lzzzz 2.0.0 lz4f/stream/decomp/read/ReadDecompressor#inner..set_dictrust-analyzer cargo lzzzz 2.0.0 lz4f/stream/decomp/bufread/impl#[`BufReadDecompressor<'a, R>`]set_dict().(dict); |
| 66 | } |
| 67 | |
| 68 | /// Reads the frame header and returns `FrameInfo`. |
| 69 | /// |
| 70 | /// Calling this function before any `Read` operations |
| 71 | /// does not consume the frame body. |
| 72 | pub fn read_frame_inforust-analyzer cargo lzzzz 2.0.0 lz4f/stream/decomp/read/impl#[`ReadDecompressor<'a, R>`]read_frame_info().(&mut self) -> stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::iorust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/::Resultrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/Result#<FrameInforust-analyzer cargo lzzzz 2.0.0 lz4f/frame_info/FrameInfo#> { |
| 73 | self.innerrust-analyzer cargo lzzzz 2.0.0 lz4f/stream/decomp/read/ReadDecompressor#inner..read_frame_inforust-analyzer cargo lzzzz 2.0.0 lz4f/stream/decomp/bufread/impl#[`BufReadDecompressor<'a, R>`]read_frame_info().() |
| 74 | } |
| 75 | |
| 76 | /// Returns ownership of the reader. |
| 77 | pub fn into_innerrust-analyzer cargo lzzzz 2.0.0 lz4f/stream/decomp/read/impl#[`ReadDecompressor<'a, R>`]into_inner().(self) -> R { |
| 78 | self.innerrust-analyzer cargo lzzzz 2.0.0 lz4f/stream/decomp/read/ReadDecompressor#inner..into_innerrust-analyzer cargo lzzzz 2.0.0 lz4f/stream/decomp/bufread/impl#[`BufReadDecompressor<'a, R>`]into_inner().().into_innerrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/buffered/bufreader/impl#[`BufReader<R>`]into_inner().() |
| 79 | } |
| 80 | |
| 81 | /// Returns a mutable reference to the reader. |
| 82 | pub fn get_mutrust-analyzer cargo lzzzz 2.0.0 lz4f/stream/decomp/read/impl#[`ReadDecompressor<'a, R>`]get_mut().(&mut self) -> &mut R { |
| 83 | self.innerrust-analyzer cargo lzzzz 2.0.0 lz4f/stream/decomp/read/ReadDecompressor#inner..get_mutrust-analyzer cargo lzzzz 2.0.0 lz4f/stream/decomp/bufread/impl#[`BufReadDecompressor<'a, R>`]get_mut().().get_mutrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/buffered/bufreader/impl#[`BufReader<R>`]get_mut().() |
| 84 | } |
| 85 | |
| 86 | /// Returns a shared reference to the reader. |
| 87 | pub fn get_refrust-analyzer cargo lzzzz 2.0.0 lz4f/stream/decomp/read/impl#[`ReadDecompressor<'a, R>`]get_ref().(&self) -> &R { |
| 88 | self.innerrust-analyzer cargo lzzzz 2.0.0 lz4f/stream/decomp/read/ReadDecompressor#inner..get_refrust-analyzer cargo lzzzz 2.0.0 lz4f/stream/decomp/bufread/impl#[`BufReadDecompressor<'a, R>`]get_ref().().get_refrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/buffered/bufreader/impl#[`BufReader<R>`]get_ref().() |
| 89 | } |
| 90 | } |
| 91 | |
| 92 | impl<R: Readrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/Read#> Readrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/Read# for ReadDecompressorrust-analyzer cargo lzzzz 2.0.0 lz4f/stream/decomp/read/ReadDecompressor#<'_, R> { |
| 93 | fn readrust-analyzer cargo lzzzz 2.0.0 lz4f/stream/decomp/read/impl#[`ReadDecompressor<'_, R>`][Read]read().(&mut self, buf: &mut [u8]) -> stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::iorust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/::Resultrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/Result#<usize> { |
| 94 | self.innerrust-analyzer cargo lzzzz 2.0.0 lz4f/stream/decomp/read/ReadDecompressor#inner..readrust-analyzer cargo lzzzz 2.0.0 lz4f/stream/decomp/bufread/impl#[`BufReadDecompressor<'_, R>`][Read]read().(buf) |
| 95 | } |
| 96 | } |