| 1 | use superrust-analyzer cargo lzzzz 2.0.0 lz4f/stream/comp/::{BufReadCompressorrust-analyzer cargo lzzzz 2.0.0 lz4f/stream/comp/bufread/BufReadCompressor#, Dictionaryrust-analyzer cargo lzzzz 2.0.0 lz4f/dictionary/Dictionary#, Preferencesrust-analyzer cargo lzzzz 2.0.0 lz4f/preferences/Preferences#}; |
| 2 | use craterust-analyzer cargo lzzzz 2.0.0 crate/::lz4frust-analyzer cargo lzzzz 2.0.0 lz4f/::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 | fmtrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc fmt/, |
| 5 | 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#}, |
| 6 | }; |
| 7 | |
| 8 | /// The [`Read`]-based streaming compressor. |
| 9 | /// |
| 10 | /// # Example |
| 11 | /// |
| 12 | /// ``` |
| 13 | /// # use std::env; |
| 14 | /// # use std::path::Path; |
| 15 | /// # use lzzzz::{Error, Result}; |
| 16 | /// # use assert_fs::prelude::*; |
| 17 | /// # let tmp_dir = assert_fs::TempDir::new().unwrap().into_persistent(); |
| 18 | /// # env::set_current_dir(tmp_dir.path()).unwrap(); |
| 19 | /// # |
| 20 | /// # tmp_dir.child("foo.txt").write_str("Hello").unwrap(); |
| 21 | /// # |
| 22 | /// use lzzzz::lz4f::ReadCompressor; |
| 23 | /// use std::{fs::File, io::prelude::*}; |
| 24 | /// |
| 25 | /// let mut f = File::open("foo.txt")?; |
| 26 | /// let mut r = ReadCompressor::new(&mut f, Default::default())?; |
| 27 | /// |
| 28 | /// let mut buf = Vec::new(); |
| 29 | /// r.read_to_end(&mut buf)?; |
| 30 | /// # Ok::<(), std::io::Error>(()) |
| 31 | /// ``` |
| 32 | /// |
| 33 | /// [`Read`]: https://doc.rust-lang.org/std/io/trait.Read.html |
| 34 | pub struct ReadCompressorrust-analyzer cargo lzzzz 2.0.0 lz4f/stream/comp/read/ReadCompressor#<R: Readrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/Read#> { |
| 35 | innerrust-analyzer cargo lzzzz 2.0.0 lz4f/stream/comp/read/ReadCompressor#inner.: BufReadCompressorrust-analyzer cargo lzzzz 2.0.0 lz4f/stream/comp/bufread/BufReadCompressor#<BufReaderrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/buffered/bufreader/BufReader#<R>>, |
| 36 | } |
| 37 | |
| 38 | impl<R: Readrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/Read#> ReadCompressorrust-analyzer cargo lzzzz 2.0.0 lz4f/stream/comp/read/ReadCompressor#<R> { |
| 39 | /// Creates a new `ReadCompressor<R>`. |
| 40 | pub fn newrust-analyzer cargo lzzzz 2.0.0 lz4f/stream/comp/read/impl#[`ReadCompressor<R>`]new().(reader: R, prefs: Preferencesrust-analyzer cargo lzzzz 2.0.0 lz4f/preferences/Preferences#) -> Resultrust-analyzer cargo lzzzz 2.0.0 lz4f/error/Result#<Selfrust-analyzer cargo lzzzz 2.0.0 lz4f/stream/comp/read/impl#[`ReadCompressor<R>`]> { |
| 41 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(Selfrust-analyzer cargo lzzzz 2.0.0 lz4f/stream/comp/read/impl#[`ReadCompressor<R>`] { |
| 42 | innerrust-analyzer cargo lzzzz 2.0.0 lz4f/stream/comp/read/ReadCompressor#inner.: BufReadCompressorrust-analyzer cargo lzzzz 2.0.0 lz4f/stream/comp/bufread/BufReadCompressor#::newrust-analyzer cargo lzzzz 2.0.0 lz4f/stream/comp/bufread/impl#[`BufReadCompressor<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), prefs)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch()., |
| 43 | }) |
| 44 | } |
| 45 | |
| 46 | /// Creates a new `ReadCompressor<R>` with a dictionary. |
| 47 | pub fn with_dictrust-analyzer cargo lzzzz 2.0.0 lz4f/stream/comp/read/impl#[`ReadCompressor<R>`]with_dict().(reader: R, prefs: Preferencesrust-analyzer cargo lzzzz 2.0.0 lz4f/preferences/Preferences#, dict: Dictionaryrust-analyzer cargo lzzzz 2.0.0 lz4f/dictionary/Dictionary#) -> Resultrust-analyzer cargo lzzzz 2.0.0 lz4f/error/Result#<Selfrust-analyzer cargo lzzzz 2.0.0 lz4f/stream/comp/read/impl#[`ReadCompressor<R>`]> { |
| 48 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(Selfrust-analyzer cargo lzzzz 2.0.0 lz4f/stream/comp/read/impl#[`ReadCompressor<R>`] { |
| 49 | innerrust-analyzer cargo lzzzz 2.0.0 lz4f/stream/comp/read/ReadCompressor#inner.: BufReadCompressorrust-analyzer cargo lzzzz 2.0.0 lz4f/stream/comp/bufread/BufReadCompressor#::with_dictrust-analyzer cargo lzzzz 2.0.0 lz4f/stream/comp/bufread/impl#[`BufReadCompressor<R>`]with_dict().(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), prefs, dict)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch()., |
| 50 | }) |
| 51 | } |
| 52 | |
| 53 | /// Returns ownership of the reader. |
| 54 | pub fn into_innerrust-analyzer cargo lzzzz 2.0.0 lz4f/stream/comp/read/impl#[`ReadCompressor<R>`]into_inner().(self) -> R { |
| 55 | self.innerrust-analyzer cargo lzzzz 2.0.0 lz4f/stream/comp/read/ReadCompressor#inner..into_innerrust-analyzer cargo lzzzz 2.0.0 lz4f/stream/comp/bufread/impl#[`BufReadCompressor<R>`]into_inner().().into_innerrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/buffered/bufreader/impl#[`BufReader<R>`]into_inner().() |
| 56 | } |
| 57 | |
| 58 | /// Returns a mutable reference to the reader. |
| 59 | pub fn get_mutrust-analyzer cargo lzzzz 2.0.0 lz4f/stream/comp/read/impl#[`ReadCompressor<R>`]get_mut().(&mut self) -> &mut R { |
| 60 | self.innerrust-analyzer cargo lzzzz 2.0.0 lz4f/stream/comp/read/ReadCompressor#inner..get_mutrust-analyzer cargo lzzzz 2.0.0 lz4f/stream/comp/bufread/impl#[`BufReadCompressor<R>`]get_mut().().get_mutrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/buffered/bufreader/impl#[`BufReader<R>`]get_mut().() |
| 61 | } |
| 62 | |
| 63 | /// Returns a shared reference to the reader. |
| 64 | pub fn get_refrust-analyzer cargo lzzzz 2.0.0 lz4f/stream/comp/read/impl#[`ReadCompressor<R>`]get_ref().(&self) -> &R { |
| 65 | self.innerrust-analyzer cargo lzzzz 2.0.0 lz4f/stream/comp/read/ReadCompressor#inner..get_refrust-analyzer cargo lzzzz 2.0.0 lz4f/stream/comp/bufread/impl#[`BufReadCompressor<R>`]get_ref().().get_refrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/buffered/bufreader/impl#[`BufReader<R>`]get_ref().() |
| 66 | } |
| 67 | } |
| 68 | |
| 69 | 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 ReadCompressorrust-analyzer cargo lzzzz 2.0.0 lz4f/stream/comp/read/ReadCompressor#<R> |
| 70 | where |
| 71 | 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#, |
| 72 | { |
| 73 | fn fmtrust-analyzer cargo lzzzz 2.0.0 lz4f/stream/comp/read/impl#[`ReadCompressor<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# { |
| 74 | fmt.debug_structrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/impl#[`Formatter<'a>`]debug_struct().("ReadCompressor") |
| 75 | .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/comp/read/ReadCompressor#inner..innerrust-analyzer cargo lzzzz 2.0.0 lz4f/stream/comp/bufread/BufReadCompressor#inner..get_refrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/buffered/bufreader/impl#[`BufReader<R>`]get_ref().()) |
| 76 | .fieldrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/builders/impl#[`DebugStruct<'a, 'b>`]field().("prefs", &self.innerrust-analyzer cargo lzzzz 2.0.0 lz4f/stream/comp/read/ReadCompressor#inner..comprust-analyzer cargo lzzzz 2.0.0 lz4f/stream/comp/bufread/BufReadCompressor#comp..prefsrust-analyzer cargo lzzzz 2.0.0 lz4f/stream/comp/impl#[Compressor]prefs().()) |
| 77 | .finishrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/builders/impl#[`DebugStruct<'a, 'b>`]finish().() |
| 78 | } |
| 79 | } |
| 80 | |
| 81 | 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 ReadCompressorrust-analyzer cargo lzzzz 2.0.0 lz4f/stream/comp/read/ReadCompressor#<R> { |
| 82 | fn readrust-analyzer cargo lzzzz 2.0.0 lz4f/stream/comp/read/impl#[`ReadCompressor<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> { |
| 83 | self.innerrust-analyzer cargo lzzzz 2.0.0 lz4f/stream/comp/read/ReadCompressor#inner..readrust-analyzer cargo lzzzz 2.0.0 lz4f/stream/comp/bufread/impl#[`BufReadCompressor<R>`][Read]read().(buf) |
| 84 | } |
| 85 | } |