Skip to content

Commit

Permalink
[git-packetline] Allow different lifetimes for writer and buffers
Browse files Browse the repository at this point in the history
  • Loading branch information
Byron committed May 15, 2021
1 parent 3299548 commit 3b3c53d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
14 changes: 7 additions & 7 deletions git-packetline/src/encode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,12 @@ mod async_io {

pin_project_lite::pin_project! {
/// A way of writing packet lines asynchronously.
pub struct LineWriter<'a, W: ?Sized> {
pub struct LineWriter<'a, 'b, W: ?Sized> {
#[pin]
writer: &'a mut W,
prefix: &'a [u8],
suffix: &'a [u8],
state: State<'a>,
prefix: &'b [u8],
suffix: &'b [u8],
state: State<'b>,
}
}
enum State<'a> {
Expand All @@ -54,11 +54,11 @@ mod async_io {
State::Idle
}
}
impl<'a, W: AsyncWrite + Unpin + ?Sized> LineWriter<'a, W> {
impl<'a, 'b, W: AsyncWrite + Unpin + ?Sized> LineWriter<'a, 'b, W> {
/// Create a new line writer writing data with a `prefix` and `suffix`.
///
/// Keep the additional `prefix` or `suffix` buffers empty if no prefix or suffix should be written.
pub fn new(writer: &'a mut W, prefix: &'a [u8], suffix: &'a [u8]) -> Self {
pub fn new(writer: &'a mut W, prefix: &'b [u8], suffix: &'b [u8]) -> Self {
LineWriter {
writer,
prefix,
Expand All @@ -68,7 +68,7 @@ mod async_io {
}
}

impl<W: AsyncWrite + Unpin + ?Sized> AsyncWrite for LineWriter<'_, W> {
impl<W: AsyncWrite + Unpin + ?Sized> AsyncWrite for LineWriter<'_, '_, W> {
fn poll_write(mut self: Pin<&mut Self>, cx: &mut Context<'_>, data: &[u8]) -> Poll<io::Result<usize>> {
use futures_lite::ready;
fn into_io_err(err: Error) -> io::Error {
Expand Down
1 change: 0 additions & 1 deletion git-packetline/src/write.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ impl<T> Writer<T> {
}
#[cfg(all(not(feature = "blocking-io"), feature = "async-io"))]
mod async_io {
// use crate::{MAX_DATA_LEN, U16_HEX_BYTES};
use futures_io::AsyncWrite;
use std::{
io,
Expand Down

0 comments on commit 3b3c53d

Please sign in to comment.