Skip to content

Commit 434f69b

Browse files
committed
Move to pin-project-lite
Closes #60
1 parent 9d905ee commit 434f69b

File tree

14 files changed

+128
-115
lines changed

14 files changed

+128
-115
lines changed

Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ bzip2 = { version = "0.3.3" , optional = true }
4242
flate2 = { version = "1.0.11", optional = true }
4343
futures-core = { version = "0.3.0", default-features = false }
4444
futures-io = { version = "0.3.0", default-features = false, features = ["std"], optional = true }
45-
pin-project = "0.4.3"
45+
pin-project-lite = "0.1.1"
4646
libzstd = { version = "0.5.0", optional = true, package = "zstd", default-features = false }
4747
zstd-safe = { version = "2.0.0", optional = true, default-features = false }
4848
memchr = "2.2.1"

src/bufread/generic/decoder.rs

+9-8
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use std::io::Result;
77
use crate::{codec::Decode, util::PartialBuffer};
88
use futures_core::ready;
99
use futures_io::{AsyncBufRead, AsyncRead};
10-
use pin_project::pin_project;
10+
use pin_project_lite::pin_project;
1111

1212
#[derive(Debug)]
1313
enum State {
@@ -16,13 +16,14 @@ enum State {
1616
Done,
1717
}
1818

19-
#[pin_project]
20-
#[derive(Debug)]
21-
pub struct Decoder<R: AsyncBufRead, D: Decode> {
22-
#[pin]
23-
reader: R,
24-
decoder: D,
25-
state: State,
19+
pin_project! {
20+
#[derive(Debug)]
21+
pub struct Decoder<R: AsyncBufRead, D: Decode> {
22+
#[pin]
23+
reader: R,
24+
decoder: D,
25+
state: State,
26+
}
2627
}
2728

2829
impl<R: AsyncBufRead, D: Decode> Decoder<R, D> {

src/bufread/generic/encoder.rs

+9-8
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use std::io::Result;
77
use crate::{codec::Encode, util::PartialBuffer};
88
use futures_core::ready;
99
use futures_io::{AsyncBufRead, AsyncRead};
10-
use pin_project::pin_project;
10+
use pin_project_lite::pin_project;
1111

1212
#[derive(Debug)]
1313
enum State {
@@ -16,13 +16,14 @@ enum State {
1616
Done,
1717
}
1818

19-
#[pin_project]
20-
#[derive(Debug)]
21-
pub struct Encoder<R: AsyncBufRead, E: Encode> {
22-
#[pin]
23-
reader: R,
24-
encoder: E,
25-
state: State,
19+
pin_project! {
20+
#[derive(Debug)]
21+
pub struct Encoder<R: AsyncBufRead, E: Encode> {
22+
#[pin]
23+
reader: R,
24+
encoder: E,
25+
state: State,
26+
}
2627
}
2728

2829
impl<R: AsyncBufRead, E: Encode> Encoder<R, E> {

src/bufread/macros/decoder.rs

+10-9
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11
macro_rules! decoder {
22
($(#[$attr:meta])* $name:ident) => {
3-
$(#[$attr])*
4-
#[pin_project::pin_project]
5-
#[derive(Debug)]
6-
///
7-
/// This structure implements an [`AsyncRead`](futures_io::AsyncRead) interface and will
8-
/// read compressed data from an underlying stream and emit a stream of uncompressed data.
9-
pub struct $name<R: futures_io::AsyncBufRead> {
10-
#[pin]
11-
inner: crate::bufread::Decoder<R, crate::codec::$name>,
3+
pin_project_lite::pin_project! {
4+
$(#[$attr])*
5+
#[derive(Debug)]
6+
///
7+
/// This structure implements an [`AsyncRead`](futures_io::AsyncRead) interface and will
8+
/// read compressed data from an underlying stream and emit a stream of uncompressed data.
9+
pub struct $name<R: futures_io::AsyncBufRead> {
10+
#[pin]
11+
inner: crate::bufread::Decoder<R, crate::codec::$name>,
12+
}
1213
}
1314

1415
impl<R: futures_io::AsyncBufRead> $name<R> {

src/bufread/macros/encoder.rs

+10-9
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11
macro_rules! encoder {
22
($(#[$attr:meta])* $name:ident<$inner:ident> $({ $($constructor:tt)* })*) => {
3-
$(#[$attr])*
4-
#[pin_project::pin_project]
5-
#[derive(Debug)]
6-
///
7-
/// This structure implements an [`AsyncRead`](futures_io::AsyncRead) interface and will
8-
/// read uncompressed data from an underlying stream and emit a stream of compressed data.
9-
pub struct $name<$inner: futures_io::AsyncBufRead> {
10-
#[pin]
11-
inner: crate::bufread::Encoder<$inner, crate::codec::$name>,
3+
pin_project_lite::pin_project! {
4+
$(#[$attr])*
5+
#[derive(Debug)]
6+
///
7+
/// This structure implements an [`AsyncRead`](futures_io::AsyncRead) interface and will
8+
/// read uncompressed data from an underlying stream and emit a stream of compressed data.
9+
pub struct $name<$inner: futures_io::AsyncBufRead> {
10+
#[pin]
11+
inner: crate::bufread::Encoder<$inner, crate::codec::$name>,
12+
}
1213
}
1314

1415
impl<$inner: futures_io::AsyncBufRead> $name<$inner> {

src/stream/generic/decoder.rs

+11-10
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use std::{
88
use crate::{codec::Decode, util::PartialBuffer};
99
use bytes::{Bytes, BytesMut};
1010
use futures_core::{ready, stream::Stream};
11-
use pin_project::pin_project;
11+
use pin_project_lite::pin_project;
1212

1313
const OUTPUT_BUFFER_SIZE: usize = 8_000;
1414

@@ -21,15 +21,16 @@ enum State {
2121
Invalid,
2222
}
2323

24-
#[pin_project]
25-
#[derive(Debug)]
26-
pub struct Decoder<S: Stream<Item = Result<Bytes>>, D: Decode> {
27-
#[pin]
28-
stream: S,
29-
decoder: D,
30-
state: State,
31-
input: Bytes,
32-
output: BytesMut,
24+
pin_project! {
25+
#[derive(Debug)]
26+
pub struct Decoder<S: Stream<Item = Result<Bytes>>, D: Decode> {
27+
#[pin]
28+
stream: S,
29+
decoder: D,
30+
state: State,
31+
input: Bytes,
32+
output: BytesMut,
33+
}
3334
}
3435

3536
impl<S: Stream<Item = Result<Bytes>>, D: Decode> Decoder<S, D> {

src/stream/generic/encoder.rs

+11-10
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use std::{
88
use crate::{codec::Encode, util::PartialBuffer};
99
use bytes::{Bytes, BytesMut};
1010
use futures_core::{ready, stream::Stream};
11-
use pin_project::pin_project;
11+
use pin_project_lite::pin_project;
1212

1313
const OUTPUT_BUFFER_SIZE: usize = 8_000;
1414

@@ -21,15 +21,16 @@ enum State {
2121
Invalid,
2222
}
2323

24-
#[pin_project]
25-
#[derive(Debug)]
26-
pub struct Encoder<S: Stream<Item = Result<Bytes>>, E: Encode> {
27-
#[pin]
28-
stream: S,
29-
encoder: E,
30-
state: State,
31-
input: Bytes,
32-
output: BytesMut,
24+
pin_project! {
25+
#[derive(Debug)]
26+
pub struct Encoder<S: Stream<Item = Result<Bytes>>, E: Encode> {
27+
#[pin]
28+
stream: S,
29+
encoder: E,
30+
state: State,
31+
input: Bytes,
32+
output: BytesMut,
33+
}
3334
}
3435

3536
impl<S: Stream<Item = Result<Bytes>>, E: Encode> Encoder<S, E> {

src/stream/macros/decoder.rs

+10-9
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11
macro_rules! decoder {
22
($(#[$attr:meta])* $name:ident) => {
3-
$(#[$attr])*
4-
#[pin_project::pin_project]
5-
#[derive(Debug)]
6-
///
7-
/// This structure implements a [`Stream`](futures_core::stream::Stream) interface and will read
8-
/// compressed data from an underlying stream and emit a stream of uncompressed data.
9-
pub struct $name<S: futures_core::stream::Stream<Item = std::io::Result<bytes::Bytes>>> {
10-
#[pin]
11-
inner: crate::stream::generic::Decoder<S, crate::codec::$name>,
3+
pin_project_lite::pin_project! {
4+
$(#[$attr])*
5+
#[derive(Debug)]
6+
///
7+
/// This structure implements a [`Stream`](futures_core::stream::Stream) interface and will read
8+
/// compressed data from an underlying stream and emit a stream of uncompressed data.
9+
pub struct $name<S: futures_core::stream::Stream<Item = std::io::Result<bytes::Bytes>>> {
10+
#[pin]
11+
inner: crate::stream::generic::Decoder<S, crate::codec::$name>,
12+
}
1213
}
1314

1415
impl<S: futures_core::stream::Stream<Item = std::io::Result<bytes::Bytes>>> $name<S> {

src/stream/macros/encoder.rs

+10-9
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11
macro_rules! encoder {
22
($(#[$attr:meta])* $name:ident<$inner:ident> $({ $($constructor:tt)* })*) => {
3-
$(#[$attr])*
4-
#[pin_project::pin_project]
5-
#[derive(Debug)]
6-
///
7-
/// This structure implements a [`Stream`](futures_core::stream::Stream) interface and will read
8-
/// uncompressed data from an underlying stream and emit a stream of compressed data.
9-
pub struct $name<$inner: futures_core::stream::Stream<Item = std::io::Result<bytes::Bytes>>> {
10-
#[pin]
11-
inner: crate::stream::Encoder<$inner, crate::codec::$name>,
3+
pin_project_lite::pin_project! {
4+
$(#[$attr])*
5+
#[derive(Debug)]
6+
///
7+
/// This structure implements a [`Stream`](futures_core::stream::Stream) interface and will read
8+
/// uncompressed data from an underlying stream and emit a stream of compressed data.
9+
pub struct $name<$inner: futures_core::stream::Stream<Item = std::io::Result<bytes::Bytes>>> {
10+
#[pin]
11+
inner: crate::stream::Encoder<$inner, crate::codec::$name>,
12+
}
1213
}
1314

1415
impl<$inner: futures_core::stream::Stream<Item = std::io::Result<bytes::Bytes>>> $name<$inner> {

src/write/buf_writer.rs

+9-8
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
use super::AsyncBufWrite;
66
use futures_core::ready;
77
use futures_io::{AsyncSeek, AsyncWrite, SeekFrom};
8-
use pin_project::pin_project;
8+
use pin_project_lite::pin_project;
99
use std::{
1010
cmp::min,
1111
fmt, io,
@@ -15,13 +15,14 @@ use std::{
1515

1616
const DEFAULT_BUF_SIZE: usize = 8192;
1717

18-
#[pin_project]
19-
pub struct BufWriter<W> {
20-
#[pin]
21-
inner: W,
22-
buf: Box<[u8]>,
23-
written: usize,
24-
buffered: usize,
18+
pin_project! {
19+
pub struct BufWriter<W> {
20+
#[pin]
21+
inner: W,
22+
buf: Box<[u8]>,
23+
written: usize,
24+
buffered: usize,
25+
}
2526
}
2627

2728
impl<W: AsyncWrite> BufWriter<W> {

src/write/generic/decoder.rs

+9-8
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ use crate::{
1111
};
1212
use futures_core::ready;
1313
use futures_io::AsyncWrite;
14-
use pin_project::pin_project;
14+
use pin_project_lite::pin_project;
1515

1616
#[derive(Debug)]
1717
enum State {
@@ -20,13 +20,14 @@ enum State {
2020
Done,
2121
}
2222

23-
#[pin_project]
24-
#[derive(Debug)]
25-
pub struct Decoder<W: AsyncWrite, D: Decode> {
26-
#[pin]
27-
writer: BufWriter<W>,
28-
decoder: D,
29-
state: State,
23+
pin_project! {
24+
#[derive(Debug)]
25+
pub struct Decoder<W: AsyncWrite, D: Decode> {
26+
#[pin]
27+
writer: BufWriter<W>,
28+
decoder: D,
29+
state: State,
30+
}
3031
}
3132

3233
impl<W: AsyncWrite, D: Decode> Decoder<W, D> {

src/write/generic/encoder.rs

+9-8
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ use crate::{
1111
};
1212
use futures_core::ready;
1313
use futures_io::AsyncWrite;
14-
use pin_project::pin_project;
14+
use pin_project_lite::pin_project;
1515

1616
#[derive(Debug)]
1717
enum State {
@@ -20,13 +20,14 @@ enum State {
2020
Done,
2121
}
2222

23-
#[pin_project]
24-
#[derive(Debug)]
25-
pub struct Encoder<W: AsyncWrite, E: Encode> {
26-
#[pin]
27-
writer: BufWriter<W>,
28-
encoder: E,
29-
state: State,
23+
pin_project! {
24+
#[derive(Debug)]
25+
pub struct Encoder<W: AsyncWrite, E: Encode> {
26+
#[pin]
27+
writer: BufWriter<W>,
28+
encoder: E,
29+
state: State,
30+
}
3031
}
3132

3233
impl<W: AsyncWrite, E: Encode> Encoder<W, E> {

src/write/macros/decoder.rs

+10-9
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11
macro_rules! decoder {
22
($(#[$attr:meta])* $name:ident) => {
3-
$(#[$attr])*
4-
#[pin_project::pin_project]
5-
#[derive(Debug)]
6-
///
7-
/// This structure implements an [`AsyncWrite`](futures_io::AsyncWrite) interface and will
8-
/// take in compressed data and write it uncompressed to an underlying stream.
9-
pub struct $name<W: futures_io::AsyncWrite> {
10-
#[pin]
11-
inner: crate::write::Decoder<W, crate::codec::$name>,
3+
pin_project_lite::pin_project! {
4+
$(#[$attr])*
5+
#[derive(Debug)]
6+
///
7+
/// This structure implements an [`AsyncWrite`](futures_io::AsyncWrite) interface and will
8+
/// take in compressed data and write it uncompressed to an underlying stream.
9+
pub struct $name<W: futures_io::AsyncWrite> {
10+
#[pin]
11+
inner: crate::write::Decoder<W, crate::codec::$name>,
12+
}
1213
}
1314

1415
impl<W: futures_io::AsyncWrite> $name<W> {

src/write/macros/encoder.rs

+10-9
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11
macro_rules! encoder {
22
($(#[$attr:meta])* $name:ident<$inner:ident> $({ $($constructor:tt)* })*) => {
3-
$(#[$attr])*
4-
#[pin_project::pin_project]
5-
#[derive(Debug)]
6-
///
7-
/// This structure implements an [`AsyncWrite`](futures_io::AsyncWrite) interface and will
8-
/// take in uncompressed data and write it compressed to an underlying stream.
9-
pub struct $name<$inner: futures_io::AsyncWrite> {
10-
#[pin]
11-
inner: crate::write::Encoder<$inner, crate::codec::$name>,
3+
pin_project_lite::pin_project! {
4+
$(#[$attr])*
5+
#[derive(Debug)]
6+
///
7+
/// This structure implements an [`AsyncWrite`](futures_io::AsyncWrite) interface and will
8+
/// take in uncompressed data and write it compressed to an underlying stream.
9+
pub struct $name<$inner: futures_io::AsyncWrite> {
10+
#[pin]
11+
inner: crate::write::Encoder<$inner, crate::codec::$name>,
12+
}
1213
}
1314

1415
impl<$inner: futures_io::AsyncWrite> $name<$inner> {

0 commit comments

Comments
 (0)