| 1 | // Copyright (c) 2022 Harry [Majored] [[email protected]] |
| 2 | // MIT License (https://github.com/Majored/rs-async-zip/blob/main/LICENSE) |
| 3 | |
| 4 | use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::pinrust-analyzer cargo core https://github.com/rust-lang/rust/library/core pin/::Pinrust-analyzer cargo core https://github.com/rust-lang/rust/library/core pin/Pin#; |
| 5 | use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::taskrust-analyzer cargo std https://github.com/rust-lang/rust/library/std task/::{Contextrust-analyzer cargo core https://github.com/rust-lang/rust/library/core task/wake/Context#, Pollrust-analyzer cargo core https://github.com/rust-lang/rust/library/core task/poll/Poll#}; |
| 6 | |
| 7 | use futures_literust-analyzer cargo futures-lite 2.1.0 crate/::iorust-analyzer cargo futures-lite 2.1.0 io/::{AsyncBufReadrust-analyzer cargo futures-io 0.3.25 if_std/AsyncBufRead#, AsyncReadrust-analyzer cargo futures-io 0.3.25 if_std/AsyncRead#}; |
| 8 | use pin_projectrust-analyzer cargo pin-project 1.0.12 crate/::pin_projectrust-analyzer cargo pin-project-internal 1.0.12 pin_project:; |
| 9 | |
| 10 | /// A wrapping reader which holds an owned R or a mutable borrow to R. |
| 11 | /// |
| 12 | /// This is used to represent whether the supplied reader can be acted on concurrently or not (with an owned value |
| 13 | /// suggesting that R implements some method of synchronisation & cloning). |
| 14 | #[pin_projectrust-analyzer cargo pin-project-internal 1.0.12 pin_project:(project = OwnedReaderProjrust-analyzer cargo async_zip 0.0.18 base/read/io/owned/OwnedReaderProj#)] |
| 15 | pub(craterust-analyzer cargo async_zip 0.0.18 crate/) enum OwnedReaderrust-analyzer cargo async_zip 0.0.18 base/read/io/owned/OwnedReader#<'a, R> { |
| 16 | Ownedrust-analyzer cargo async_zip 0.0.18 base/read/io/owned/OwnedReader#Owned#(#[pin] R), |
| 17 | Borrowrust-analyzer cargo async_zip 0.0.18 base/read/io/owned/OwnedReader#Borrow#(#[pin] &'a mut R), |
| 18 | } |
| 19 | |
| 20 | impl<'a, R> OwnedReaderrust-analyzer cargo async_zip 0.0.18 base/read/io/owned/OwnedReader#<'a, R> |
| 21 | where |
| 22 | R: AsyncBufReadrust-analyzer cargo futures-io 0.3.25 if_std/AsyncBufRead# + Unpinrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Unpin#, |
| 23 | { |
| 24 | /// Consumes an owned reader and returns the inner value. |
| 25 | pub(craterust-analyzer cargo async_zip 0.0.18 crate/) fn owned_into_innerrust-analyzer cargo async_zip 0.0.18 base/read/io/owned/impl#[`OwnedReader<'a, R>`]owned_into_inner().(self) -> R { |
| 26 | match self { |
| 27 | OwnedReaderrust-analyzer cargo async_zip 0.0.18 base/read/io/owned/OwnedReader#::Ownedrust-analyzer cargo async_zip 0.0.18 base/read/io/owned/OwnedReader#Owned#(inner) => inner, |
| 28 | OwnedReaderrust-analyzer cargo async_zip 0.0.18 base/read/io/owned/OwnedReader#::Borrowrust-analyzer cargo async_zip 0.0.18 base/read/io/owned/OwnedReader#Borrow#(_) => panicrust-analyzer cargo std https://github.com/rust-lang/rust/library/std macros/panic!!("not OwnedReader::Owned value"), |
| 29 | } |
| 30 | } |
| 31 | } |
| 32 | |
| 33 | impl<'a, R> AsyncBufReadrust-analyzer cargo futures-io 0.3.25 if_std/AsyncBufRead# for OwnedReaderrust-analyzer cargo async_zip 0.0.18 base/read/io/owned/OwnedReader#<'a, R> |
| 34 | where |
| 35 | R: AsyncBufReadrust-analyzer cargo futures-io 0.3.25 if_std/AsyncBufRead# + Unpinrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Unpin#, |
| 36 | { |
| 37 | fn poll_fill_bufrust-analyzer cargo async_zip 0.0.18 base/read/io/owned/impl#[`OwnedReader<'a, R>`][AsyncBufRead]poll_fill_buf().(self: Pinrust-analyzer cargo core https://github.com/rust-lang/rust/library/core pin/Pin#<&mut Selfrust-analyzer cargo async_zip 0.0.18 base/read/io/owned/impl#[`OwnedReader<'a, R>`][AsyncBufRead]>, cx: &mut Contextrust-analyzer cargo core https://github.com/rust-lang/rust/library/core task/wake/Context#<'_>) -> Pollrust-analyzer cargo core https://github.com/rust-lang/rust/library/core task/poll/Poll#<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#<&[u8]>> { |
| 38 | match self.projectrust-analyzer cargo async_zip 0.0.18 base/read/io/owned/impl#[`OwnedReader<'a, R>`]project().() { |
| 39 | OwnedReaderProjrust-analyzer cargo async_zip 0.0.18 base/read/io/owned/OwnedReaderProj#::Ownedrust-analyzer cargo async_zip 0.0.18 base/read/io/owned/OwnedReaderProj#Owned#(inner) => inner.poll_fill_bufrust-analyzer cargo futures-io 0.3.25 if_std/AsyncBufRead#poll_fill_buf().(cx), |
| 40 | OwnedReaderProjrust-analyzer cargo async_zip 0.0.18 base/read/io/owned/OwnedReaderProj#::Borrowrust-analyzer cargo async_zip 0.0.18 base/read/io/owned/OwnedReaderProj#Borrow#(inner) => inner.poll_fill_bufrust-analyzer cargo futures-io 0.3.25 if_std/impl#[`&mut T`][AsyncBufRead]poll_fill_buf().(cx), |
| 41 | } |
| 42 | } |
| 43 | |
| 44 | fn consumerust-analyzer cargo async_zip 0.0.18 base/read/io/owned/impl#[`OwnedReader<'a, R>`][AsyncBufRead]consume().(self: Pinrust-analyzer cargo core https://github.com/rust-lang/rust/library/core pin/Pin#<&mut Selfrust-analyzer cargo async_zip 0.0.18 base/read/io/owned/impl#[`OwnedReader<'a, R>`][AsyncBufRead]>, amt: usize) { |
| 45 | match self.projectrust-analyzer cargo async_zip 0.0.18 base/read/io/owned/impl#[`OwnedReader<'a, R>`]project().() { |
| 46 | OwnedReaderProjrust-analyzer cargo async_zip 0.0.18 base/read/io/owned/OwnedReaderProj#::Ownedrust-analyzer cargo async_zip 0.0.18 base/read/io/owned/OwnedReaderProj#Owned#(inner) => inner.consumerust-analyzer cargo futures-io 0.3.25 if_std/AsyncBufRead#consume().(amt), |
| 47 | OwnedReaderProjrust-analyzer cargo async_zip 0.0.18 base/read/io/owned/OwnedReaderProj#::Borrowrust-analyzer cargo async_zip 0.0.18 base/read/io/owned/OwnedReaderProj#Borrow#(inner) => inner.consumerust-analyzer cargo futures-io 0.3.25 if_std/impl#[`&mut T`][AsyncBufRead]consume().(amt), |
| 48 | } |
| 49 | } |
| 50 | } |
| 51 | |
| 52 | impl<'a, R> AsyncReadrust-analyzer cargo futures-io 0.3.25 if_std/AsyncRead# for OwnedReaderrust-analyzer cargo async_zip 0.0.18 base/read/io/owned/OwnedReader#<'a, R> |
| 53 | where |
| 54 | R: AsyncBufReadrust-analyzer cargo futures-io 0.3.25 if_std/AsyncBufRead# + Unpinrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Unpin#, |
| 55 | { |
| 56 | fn poll_readrust-analyzer cargo async_zip 0.0.18 base/read/io/owned/impl#[`OwnedReader<'a, R>`][AsyncRead]poll_read().(self: Pinrust-analyzer cargo core https://github.com/rust-lang/rust/library/core pin/Pin#<&mut Selfrust-analyzer cargo async_zip 0.0.18 base/read/io/owned/impl#[`OwnedReader<'a, R>`][AsyncRead]>, c: &mut Contextrust-analyzer cargo core https://github.com/rust-lang/rust/library/core task/wake/Context#<'_>, b: &mut [u8]) -> Pollrust-analyzer cargo core https://github.com/rust-lang/rust/library/core task/poll/Poll#<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>> { |
| 57 | match self.projectrust-analyzer cargo async_zip 0.0.18 base/read/io/owned/impl#[`OwnedReader<'a, R>`]project().() { |
| 58 | OwnedReaderProjrust-analyzer cargo async_zip 0.0.18 base/read/io/owned/OwnedReaderProj#::Ownedrust-analyzer cargo async_zip 0.0.18 base/read/io/owned/OwnedReaderProj#Owned#(inner) => inner.poll_readrust-analyzer cargo futures-io 0.3.25 if_std/AsyncRead#poll_read().(c, b), |
| 59 | OwnedReaderProjrust-analyzer cargo async_zip 0.0.18 base/read/io/owned/OwnedReaderProj#::Borrowrust-analyzer cargo async_zip 0.0.18 base/read/io/owned/OwnedReaderProj#Borrow#(inner) => inner.poll_readrust-analyzer cargo futures-io 0.3.25 if_std/impl#[`&mut T`][AsyncRead]poll_read().(c, b), |
| 60 | } |
| 61 | } |
| 62 | } |