| 1 | // Copyright (c) 2022 Harry [Majored] [[email protected]] |
| 2 | // MIT License (https://github.com/Majored/rs-async-zip/blob/main/LICENSE) |
| 3 | |
| 4 | use futures_lite::io::AsyncWrite; |
| 5 | use std::io::Error; |
| 6 | use std::pin::Pin; |
| 7 | use std::task::{Context, Poll}; |
| 8 | |
| 9 | pub(crate) mod offset; |
| 10 | mod zip64; |
| 11 | |
| 12 | /// /dev/null for AsyncWrite. |
| 13 | /// Useful for tests that involve writing, but not reading, large amounts of data. |
| 14 | pub(crate) struct AsyncSink; |
| 15 | |
| 16 | // AsyncSink is always ready to receive bytes and throw them away. |
| 17 | impl AsyncWrite for AsyncSink { |
| 18 | fn poll_write(self: Pin<&mut Self>, _: &mut Context<'_>, buf: &[u8]) -> Poll<Result<usize, Error>> { |
| 19 | Poll::Ready(Ok(buf.len())) |
| 20 | } |
| 21 | |
| 22 | fn poll_flush(self: Pin<&mut Self>, _: &mut Context<'_>) -> Poll<Result<(), Error>> { |
| 23 | Poll::Ready(Ok(())) |
| 24 | } |
| 25 | |
| 26 | fn poll_close(self: Pin<&mut Self>, _: &mut Context<'_>) -> Poll<Result<(), Error>> { |
| 27 | Poll::Ready(Ok(())) |
| 28 | } |
| 29 | } |