Skip to content

Commit

Permalink
[git-packetline] Switch back to pin-project-lite
Browse files Browse the repository at this point in the history
  • Loading branch information
Byron committed May 18, 2021
1 parent fed6c69 commit 63cb0fc
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 38 deletions.
22 changes: 1 addition & 21 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions git-packetline/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ doctest = false
[features]
default = []
serde1 = ["serde", "bstr/serde1"]
async-io = ["futures-io", "futures-lite", "pin-project"]
async-io = ["futures-io", "futures-lite", "pin-project-lite"]
blocking-io = []

[[test]]
Expand All @@ -38,7 +38,7 @@ bstr = { version = "0.2.13", default-features = false, features = ["std"] }
# async support
futures-io = { version = "0.3.15", optional = true }
futures-lite = { version = "1.11.3", optional = true }
pin-project = { version = "1.0.7", optional = true }
pin-project-lite = { version = "0.2.6", optional = true }

[dev-dependencies]
async-std = { version = "1.9.0", features = ["attributes"] }
Expand Down
17 changes: 9 additions & 8 deletions git-packetline/src/encode/async_io.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,16 @@ use std::{
task::{Context, Poll},
};

/// A way of writing packet lines asynchronously.
#[allow(missing_docs)]
#[pin_project::pin_project]
pub struct LineWriter<'a, W> {
#[pin]
pub writer: W,
pub prefix: &'a [u8],
pub suffix: &'a [u8],
state: State<'a>,
pin_project_lite::pin_project! {
/// A way of writing packet lines asynchronously.
pub struct LineWriter<'a, W> {
#[pin]
pub(crate) writer: W,
pub(crate) prefix: &'a [u8],
pub(crate) suffix: &'a [u8],
state: State<'a>,
}
}

enum State<'a> {
Expand Down
15 changes: 8 additions & 7 deletions git-packetline/src/write/async_io.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,14 @@ use std::{
task::{Context, Poll},
};

/// An implementor of [`Write`][io::Write] which passes all input to an inner `Write` in packet line data encoding,
/// one line per `write(…)` call or as many lines as it takes if the data doesn't fit into the maximum allowed line length.
#[pin_project::pin_project]
pub struct Writer<T> {
#[pin]
inner: encode::LineWriter<'static, T>,
state: State,
pin_project_lite::pin_project! {
/// An implementor of [`Write`][io::Write] which passes all input to an inner `Write` in packet line data encoding,
/// one line per `write(…)` call or as many lines as it takes if the data doesn't fit into the maximum allowed line length.
pub struct Writer<T> {
#[pin]
inner: encode::LineWriter<'static, T>,
state: State,
}
}

enum State {
Expand Down

0 comments on commit 63cb0fc

Please sign in to comment.