| 1 | // Copyright (c) 2022 Harry [Majored] [[email protected]] |
| 2 | // MIT License (https://github.com/Majored/rs-async-zip/blob/main/LICENSE) |
| 3 | |
| 4 | pub(craterust-analyzer cargo async_zip 0.0.18 crate/) mod combined_recordrust-analyzer cargo async_zip 0.0.18 base/read/io/combined_record/; |
| 5 | pub(craterust-analyzer cargo async_zip 0.0.18 crate/) mod compressedrust-analyzer cargo async_zip 0.0.18 base/read/io/compressed/; |
| 6 | pub(craterust-analyzer cargo async_zip 0.0.18 crate/) mod entryrust-analyzer cargo async_zip 0.0.18 base/read/io/entry/; |
| 7 | pub(craterust-analyzer cargo async_zip 0.0.18 crate/) mod hashedrust-analyzer cargo async_zip 0.0.18 base/read/io/hashed/; |
| 8 | pub(craterust-analyzer cargo async_zip 0.0.18 crate/) mod locatorrust-analyzer cargo async_zip 0.0.18 base/read/io/locator/; |
| 9 | pub(craterust-analyzer cargo async_zip 0.0.18 crate/) mod ownedrust-analyzer cargo async_zip 0.0.18 base/read/io/owned/; |
| 10 | |
| 11 | pub use combined_recordrust-analyzer cargo async_zip 0.0.18 base/read/io/combined_record/::CombinedCentralDirectoryRecordrust-analyzer cargo async_zip 0.0.18 base/read/io/combined_record/CombinedCentralDirectoryRecord#; |
| 12 | |
| 13 | use craterust-analyzer cargo async_zip 0.0.18 crate/::stringrust-analyzer cargo async_zip 0.0.18 string/::{StringEncodingrust-analyzer cargo async_zip 0.0.18 string/StringEncoding#, ZipStringrust-analyzer cargo async_zip 0.0.18 string/ZipString#}; |
| 14 | use futures_literust-analyzer cargo futures-lite 2.1.0 crate/::iorust-analyzer cargo futures-lite 2.1.0 io/::{AsyncReadrust-analyzer cargo futures-io 0.3.25 if_std/AsyncRead#, AsyncReadExtrust-analyzer cargo futures-lite 2.1.0 io/AsyncReadExt#}; |
| 15 | |
| 16 | /// Read and return a dynamic length string from a reader which impls AsyncRead. |
| 17 | pub(craterust-analyzer cargo async_zip 0.0.18 crate/) async fn read_stringrust-analyzer cargo async_zip 0.0.18 base/read/io/read_string().<R>(reader: R, length: usize, encoding: StringEncodingrust-analyzer cargo async_zip 0.0.18 string/StringEncoding#) -> 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#<ZipStringrust-analyzer cargo async_zip 0.0.18 string/ZipString#> |
| 18 | where |
| 19 | R: AsyncReadrust-analyzer cargo futures-io 0.3.25 if_std/AsyncRead# + Unpinrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Unpin#, |
| 20 | { |
| 21 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(ZipStringrust-analyzer cargo async_zip 0.0.18 string/ZipString#::newrust-analyzer cargo async_zip 0.0.18 string/impl#[ZipString]new().(read_bytesrust-analyzer cargo async_zip 0.0.18 base/read/io/read_bytes().(reader, length).rust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().awaitrust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch()., encoding)) |
| 22 | } |
| 23 | |
| 24 | /// Read and return a dynamic length vector of bytes from a reader which impls AsyncRead. |
| 25 | pub(craterust-analyzer cargo async_zip 0.0.18 crate/) async fn read_bytesrust-analyzer cargo async_zip 0.0.18 base/read/io/read_bytes().<R>(reader: R, length: usize) -> 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#<Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<u8>> |
| 26 | where |
| 27 | R: AsyncReadrust-analyzer cargo futures-io 0.3.25 if_std/AsyncRead# + Unpinrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Unpin#, |
| 28 | { |
| 29 | let mut buffer = Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#::with_capacityrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T>`]with_capacity().(length); |
| 30 | reader.takerust-analyzer cargo futures-lite 2.1.0 io/AsyncReadExt#take().(length as u64).read_to_endrust-analyzer cargo futures-lite 2.1.0 io/AsyncReadExt#read_to_end().(&mut buffer).rust-analyzer cargo futures-lite 2.1.0 io/impl#[`ReadToEndFuture<'_, R>`][Future]poll().awaitrust-analyzer cargo futures-lite 2.1.0 io/impl#[`ReadToEndFuture<'_, R>`][Future]poll().?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 31 | |
| 32 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(buffer) |
| 33 | } |
| 34 | |
| 35 | /// A macro that returns the inner value of an Ok or early-returns in the case of an Err. |
| 36 | /// |
| 37 | /// This is almost identical to the ? operator but handles the situation when a Result is used in combination with |
| 38 | /// Poll (eg. tokio's IO traits such as AsyncRead). |
| 39 | macro_rules! poll_result_okrust-analyzer cargo async_zip 0.0.18 base/read/io/poll_result_ok! { |
| 40 | ($poll:expr) => { |
| 41 | match $poll { |
| 42 | Ok(inner) => inner, |
| 43 | Err(err) => return Poll::Ready(Err(err)), |
| 44 | } |
| 45 | }; |
| 46 | } |
| 47 | |
| 48 | use poll_result_okrust-analyzer cargo async_zip 0.0.18 base/read/io/poll_result_ok!; |