1
1
macro_rules! decoder {
2
- ( $( #[ $attr: meta] ) * $name: ident<$inner : ident> $( { $( $constructor : tt) * } ) * ) => {
2
+ ( $( #[ $attr: meta] ) * $name: ident $( { $( $inherent_methods : tt) * } ) * ) => {
3
3
pin_project_lite:: pin_project! {
4
4
$( #[ $attr] ) *
5
5
///
6
6
/// This structure implements an [`AsyncRead`](futures_io::AsyncRead) interface and will
7
7
/// read compressed data from an underlying stream and emit a stream of uncompressed data.
8
8
#[ derive( Debug ) ]
9
- pub struct $name<$inner > {
9
+ pub struct $name<R > {
10
10
#[ pin]
11
- inner: crate :: futures:: bufread:: Decoder <$inner , crate :: codec:: $name>,
11
+ inner: crate :: futures:: bufread:: Decoder <R , crate :: codec:: $name>,
12
12
}
13
13
}
14
14
15
- impl <$inner : futures_io:: AsyncBufRead > $name<$inner > {
15
+ impl <R : futures_io:: AsyncBufRead > $name<R > {
16
16
/// Creates a new decoder which will read compressed data from the given stream and
17
17
/// emit a uncompressed stream.
18
- pub fn new( read: $inner ) -> $name<$inner > {
18
+ pub fn new( read: R ) -> $name<R > {
19
19
$name {
20
20
inner: crate :: futures:: bufread:: Decoder :: new( read, crate :: codec:: $name:: new( ) ) ,
21
21
}
22
22
}
23
23
24
- $(
25
- $( $constructor) *
26
- ) *
24
+ $( $( $inherent_methods) * ) *
27
25
28
26
/// Configure multi-member/frame decoding, if enabled this will reset the decoder state
29
27
/// when reaching the end of a compressed member/frame and expect either EOF or another
@@ -33,7 +31,7 @@ macro_rules! decoder {
33
31
}
34
32
35
33
/// Acquires a reference to the underlying reader that this decoder is wrapping.
36
- pub fn get_ref( & self ) -> & $inner {
34
+ pub fn get_ref( & self ) -> & R {
37
35
self . inner. get_ref( )
38
36
}
39
37
@@ -42,7 +40,7 @@ macro_rules! decoder {
42
40
///
43
41
/// Note that care must be taken to avoid tampering with the state of the reader which
44
42
/// may otherwise confuse this decoder.
45
- pub fn get_mut( & mut self ) -> & mut $inner {
43
+ pub fn get_mut( & mut self ) -> & mut R {
46
44
self . inner. get_mut( )
47
45
}
48
46
@@ -51,20 +49,20 @@ macro_rules! decoder {
51
49
///
52
50
/// Note that care must be taken to avoid tampering with the state of the reader which
53
51
/// may otherwise confuse this decoder.
54
- pub fn get_pin_mut( self : std:: pin:: Pin <& mut Self >) -> std:: pin:: Pin <& mut $inner > {
52
+ pub fn get_pin_mut( self : std:: pin:: Pin <& mut Self >) -> std:: pin:: Pin <& mut R > {
55
53
self . project( ) . inner. get_pin_mut( )
56
54
}
57
55
58
56
/// Consumes this decoder returning the underlying reader.
59
57
///
60
58
/// Note that this may discard internal state of this decoder, so care should be taken
61
59
/// to avoid losing resources when this is called.
62
- pub fn into_inner( self ) -> $inner {
60
+ pub fn into_inner( self ) -> R {
63
61
self . inner. into_inner( )
64
62
}
65
63
}
66
64
67
- impl <$inner : futures_io:: AsyncBufRead > futures_io:: AsyncRead for $name<$inner > {
65
+ impl <R : futures_io:: AsyncBufRead > futures_io:: AsyncRead for $name<R > {
68
66
fn poll_read(
69
67
self : std:: pin:: Pin <& mut Self >,
70
68
cx: & mut std:: task:: Context <' _>,
0 commit comments