Unified · Split
| @@ -15,26 +15,22 @@ type ReadLineResult<'a> = Option<std::io::Result<Result<PacketLine<'a>, decode:: · 14 unmodified lines | ||
| 15 | 15 | /// An implementor of [`AsyncBufRead`] yielding packet lines on each call to [`read_line()`][AsyncBufRead::read_line()]. |
| 16 | 16 | /// It's also possible to hide the underlying packet lines using the [`Read`][AsyncRead] implementation which is useful |
| 17 | 17 | /// if they represent binary data, like the one of a pack file. |
| 18 | −#[pin_project::pin_project(PinnedDrop)] | |
| 19 | 18 | pub struct WithSidebands<'a, T, F> |
| 20 | 19 | where |
| 21 | 20 | T: AsyncRead, |
| 22 | 21 | { |
| 23 | − #[pin] | |
| 24 | 22 | state: State<'a, T>, |
| 25 | 23 | handle_progress: Option<F>, |
| 26 | 24 | pos: usize, |
| 27 | 25 | cap: usize, |
| 28 | 26 | } |
| 29 | 27 | |
| 30 | −#[pin_project::pinned_drop] | |
| 31 | −impl<'a, T, F> PinnedDrop for WithSidebands<'a, T, F> | |
| 28 | +impl<'a, T, F> Drop for WithSidebands<'a, T, F> | |
| 32 | 29 | where |
| 33 | 30 | T: AsyncRead, |
| 34 | 31 | { |
| 35 | − fn drop(mut self: Pin<&mut Self>) { | |
| 36 | − let this = self.project(); | |
| 37 | − if let State::Idle { parent } = this.state.get_mut() { | |
| 32 | + fn drop(&mut self) { | |
| 33 | + if let State::Idle { parent } = self.state { | |
| 38 | 34 | parent.reset(); |
| 39 | 35 | } |
| 40 | 36 | } |
| @@ -131,7 +127,7 @@ where · 90 unmodified lines | ||
| 131 | 127 | impl<'a, T, F> AsyncBufRead for WithSidebands<'a, T, F> |
| 132 | 128 | where |
| 133 | 129 | T: AsyncRead + Unpin + Send, |
| 134 | − F: FnMut(bool, &[u8]), | |
| 130 | + F: FnMut(bool, &[u8]) + Unpin, | |
| 135 | 131 | { |
| 136 | 132 | fn poll_fill_buf(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<std::io::Result<&[u8]>> { |
| 137 | 133 | use futures_lite::FutureExt; |
| @@ -200,15 +196,14 @@ where · 62 unmodified lines | ||
| 200 | 196 | } |
| 201 | 197 | |
| 202 | 198 | fn consume(self: Pin<&mut Self>, amt: usize) { |
| 203 | − let this = self.project(); | |
| 204 | − *this.pos = std::cmp::min(*this.pos + amt, *this.cap); | |
| 199 | + self.pos = std::cmp::min(self.pos + amt, self.cap); | |
| 205 | 200 | } |
| 206 | 201 | } |
| 207 | 202 | |
| 208 | 203 | impl<'a, T, F> AsyncRead for WithSidebands<'a, T, F> |
| 209 | 204 | where |
| 210 | 205 | T: AsyncRead + Unpin + Send, |
| 211 | − F: FnMut(bool, &[u8]), | |
| 206 | + F: FnMut(bool, &[u8]) + Unpin, | |
| 212 | 207 | { |
| 213 | 208 | fn poll_read(mut self: Pin<&mut Self>, cx: &mut Context<'_>, buf: &mut [u8]) -> Poll<std::io::Result<usize>> { |
| 214 | 209 | let nread = { |