@@ -53,21 +53,19 @@ impl<S> PacketAsyncRead<S> for ConnAck
53
53
where
54
54
S : tokio:: io:: AsyncRead + Unpin ,
55
55
{
56
- fn async_read ( _: u8 , _: usize , stream : & mut S ) -> impl std:: future:: Future < Output = Result < ( Self , usize ) , super :: error:: ReadError > > {
57
- async move {
58
- let ( connack_flags, read_bytes) = ConnAckFlags :: async_read ( stream) . await ?;
59
- let ( reason_code, reason_code_read_bytes) = ConnAckReasonCode :: async_read ( stream) . await ?;
60
- let ( connack_properties, connack_properties_read_bytes) = ConnAckProperties :: async_read ( stream) . await ?;
61
-
62
- Ok ( (
63
- Self {
64
- connack_flags,
65
- reason_code,
66
- connack_properties,
67
- } ,
68
- read_bytes + reason_code_read_bytes + connack_properties_read_bytes,
69
- ) )
70
- }
56
+ async fn async_read ( _: u8 , _: usize , stream : & mut S ) -> Result < ( Self , usize ) , super :: error:: ReadError > {
57
+ let ( connack_flags, read_bytes) = ConnAckFlags :: async_read ( stream) . await ?;
58
+ let ( reason_code, reason_code_read_bytes) = ConnAckReasonCode :: async_read ( stream) . await ?;
59
+ let ( connack_properties, connack_properties_read_bytes) = ConnAckProperties :: async_read ( stream) . await ?;
60
+
61
+ Ok ( (
62
+ Self {
63
+ connack_flags,
64
+ reason_code,
65
+ connack_properties,
66
+ } ,
67
+ read_bytes + reason_code_read_bytes + connack_properties_read_bytes,
68
+ ) )
71
69
}
72
70
}
73
71
@@ -85,15 +83,13 @@ impl<S> crate::packets::mqtt_trait::PacketAsyncWrite<S> for ConnAck
85
83
where
86
84
S : tokio:: io:: AsyncWrite + Unpin ,
87
85
{
88
- fn async_write ( & self , stream : & mut S ) -> impl std:: future:: Future < Output = Result < usize , crate :: packets:: error:: WriteError > > {
89
- async move {
90
- use crate :: packets:: mqtt_trait:: MqttAsyncWrite ;
91
- let connack_flags_writen = self . connack_flags . async_write ( stream) . await ?;
92
- let reason_code_writen = self . reason_code . async_write ( stream) . await ?;
93
- let connack_properties_writen = self . connack_properties . async_write ( stream) . await ?;
94
-
95
- Ok ( connack_flags_writen + reason_code_writen + connack_properties_writen)
96
- }
86
+ async fn async_write ( & self , stream : & mut S ) -> Result < usize , crate :: packets:: error:: WriteError > {
87
+ use crate :: packets:: mqtt_trait:: MqttAsyncWrite ;
88
+ let connack_flags_writen = self . connack_flags . async_write ( stream) . await ?;
89
+ let reason_code_writen = self . reason_code . async_write ( stream) . await ?;
90
+ let connack_properties_writen = self . connack_properties . async_write ( stream) . await ?;
91
+
92
+ Ok ( connack_flags_writen + reason_code_writen + connack_properties_writen)
97
93
}
98
94
}
99
95
@@ -114,16 +110,14 @@ impl<S> MqttAsyncRead<S> for ConnAckFlags
114
110
where
115
111
S : tokio:: io:: AsyncRead + Unpin ,
116
112
{
117
- fn async_read ( stream : & mut S ) -> impl std:: future:: Future < Output = Result < ( Self , usize ) , super :: error:: ReadError > > {
118
- async move {
119
- let byte = stream. read_u8 ( ) . await ?;
120
- Ok ( (
121
- Self {
122
- session_present : ( byte & 0b00000001 ) == 0b00000001 ,
123
- } ,
124
- 1 ,
125
- ) )
126
- }
113
+ async fn async_read ( stream : & mut S ) -> Result < ( Self , usize ) , super :: error:: ReadError > {
114
+ let byte = stream. read_u8 ( ) . await ?;
115
+ Ok ( (
116
+ Self {
117
+ session_present : ( byte & 0b00000001 ) == 0b00000001 ,
118
+ } ,
119
+ 1 ,
120
+ ) )
127
121
}
128
122
}
129
123
@@ -154,14 +148,12 @@ impl<S> crate::packets::mqtt_trait::MqttAsyncWrite<S> for ConnAckFlags
154
148
where
155
149
S : tokio:: io:: AsyncWrite + Unpin ,
156
150
{
157
- fn async_write ( & self , stream : & mut S ) -> impl std:: future:: Future < Output = Result < usize , crate :: packets:: error:: WriteError > > {
158
- async move {
159
- use tokio:: io:: AsyncWriteExt ;
160
- let byte = self . session_present as u8 ;
151
+ async fn async_write ( & self , stream : & mut S ) -> Result < usize , crate :: packets:: error:: WriteError > {
152
+ use tokio:: io:: AsyncWriteExt ;
153
+ let byte = self . session_present as u8 ;
161
154
162
- stream. write_u8 ( byte) . await ?;
163
- Ok ( 1 )
164
- }
155
+ stream. write_u8 ( byte) . await ?;
156
+ Ok ( 1 )
165
157
}
166
158
}
167
159
0 commit comments