| 1 | use 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/; |
| 2 | |
| 3 | use superrust-analyzer cargo zstd 0.13.3 stream/::{Decoderrust-analyzer cargo zstd 0.13.3 stream/read/Decoder#, Encoderrust-analyzer cargo zstd 0.13.3 stream/write/Encoder#}; |
| 4 | |
| 5 | /// Decompress from the given source as if using a `Decoder`. |
| 6 | /// |
| 7 | /// The input data must be in the zstd frame format. |
| 8 | pub fn decode_allrust-analyzer cargo zstd 0.13.3 stream/functions/decode_all().<R: iorust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/::Readrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/Read#>(source: R) -> 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#<Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<u8>> { |
| 9 | let mut result = Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#::newrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T>`]new().(); |
| 10 | copy_decoderust-analyzer cargo zstd 0.13.3 stream/functions/copy_decode().(source, &mut result)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 11 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(result) |
| 12 | } |
| 13 | |
| 14 | /// Decompress from the given source as if using a `Decoder`. |
| 15 | /// |
| 16 | /// Decompressed data will be appended to `destination`. |
| 17 | pub fn copy_decoderust-analyzer cargo zstd 0.13.3 stream/functions/copy_decode().<R, W>(source: R, mut destination: W) -> 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#<()> |
| 18 | where |
| 19 | R: iorust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/::Readrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/Read#, |
| 20 | W: iorust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/::Writerust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/Write#, |
| 21 | { |
| 22 | let mut decoder = Decoderrust-analyzer cargo zstd 0.13.3 stream/read/Decoder#::newrust-analyzer cargo zstd 0.13.3 stream/read/impl#[`Decoder<'static, BufReader<R>>`]new().(source)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 23 | iorust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/::copyrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/copy/copy().(&mut decoder, &mut destination)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 24 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(()) |
| 25 | } |
| 26 | |
| 27 | /// Compress all data from the given source as if using an `Encoder`. |
| 28 | /// |
| 29 | /// Result will be in the zstd frame format. |
| 30 | /// |
| 31 | /// A level of `0` uses zstd's default (currently `3`). |
| 32 | pub fn encode_allrust-analyzer cargo zstd 0.13.3 stream/functions/encode_all().<R: iorust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/::Readrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/Read#>(source: R, level: i32) -> 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#<Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<u8>> { |
| 33 | let mut result = Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#::<u8>::newrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T>`]new().(); |
| 34 | copy_encoderust-analyzer cargo zstd 0.13.3 stream/functions/copy_encode().(source, &mut result, level)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 35 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(result) |
| 36 | } |
| 37 | |
| 38 | /// Compress all data from the given source as if using an `Encoder`. |
| 39 | /// |
| 40 | /// Compressed data will be appended to `destination`. |
| 41 | /// |
| 42 | /// A level of `0` uses zstd's default (currently `3`). |
| 43 | pub fn copy_encoderust-analyzer cargo zstd 0.13.3 stream/functions/copy_encode().<R, W>( |
| 44 | mut source: R, |
| 45 | destination: W, |
| 46 | level: i32, |
| 47 | ) -> 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#<()> |
| 48 | where |
| 49 | R: iorust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/::Readrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/Read#, |
| 50 | W: iorust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/::Writerust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/Write#, |
| 51 | { |
| 52 | let mut encoder = Encoderrust-analyzer cargo zstd 0.13.3 stream/write/Encoder#::newrust-analyzer cargo zstd 0.13.3 stream/write/impl#[`Encoder<'static, W>`]new().(destination, level)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 53 | iorust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/::copyrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/copy/copy().(&mut source, &mut encoder)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 54 | encoder.finishrust-analyzer cargo zstd 0.13.3 stream/write/impl#[`Encoder<'a, W>`]finish().()?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 55 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(()) |
| 56 | } |
| 57 | |
| 58 | #[cfg(test)] |
| 59 | mod testsrust-analyzer cargo zstd 0.13.3 stream/functions/tests/ {} |