@@ -108,39 +108,12 @@ pub mod hyper {
108
108
use http_body_util:: { BodyExt , Full } ;
109
109
use hyper:: body:: { Body as HttpBody , Frame } ;
110
110
use hyper_util:: client:: legacy:: { connect:: Connect , Client } ;
111
- use std:: convert:: Infallible ;
112
111
use std:: fmt:: Debug ;
113
112
use std:: pin:: Pin ;
114
113
use std:: task:: { self , Poll } ;
115
114
use std:: time:: Duration ;
116
115
use tokio:: time;
117
116
118
- pub struct Body ( Full < Bytes > ) ;
119
-
120
- impl HttpBody for Body {
121
- type Data = Bytes ;
122
- type Error = Infallible ;
123
-
124
- #[ inline]
125
- fn poll_frame (
126
- self : Pin < & mut Self > ,
127
- cx : & mut task:: Context < ' _ > ,
128
- ) -> Poll < Option < Result < Frame < Self :: Data > , Self :: Error > > > {
129
- let inner_body = unsafe { self . map_unchecked_mut ( |b| & mut b. 0 ) } ;
130
- inner_body. poll_frame ( cx)
131
- }
132
-
133
- #[ inline]
134
- fn is_end_stream ( & self ) -> bool {
135
- self . 0 . is_end_stream ( )
136
- }
137
-
138
- #[ inline]
139
- fn size_hint ( & self ) -> hyper:: body:: SizeHint {
140
- self . 0 . size_hint ( )
141
- }
142
- }
143
-
144
117
#[ derive( Debug , Clone ) ]
145
118
pub struct HyperClient < C > {
146
119
inner : Client < C , Body > ,
@@ -194,6 +167,32 @@ pub mod hyper {
194
167
Ok ( http_response. error_for_status ( ) ?)
195
168
}
196
169
}
170
+
171
+ pub struct Body ( Full < Bytes > ) ;
172
+
173
+ impl HttpBody for Body {
174
+ type Data = Bytes ;
175
+ type Error = Box < dyn std:: error:: Error + Send + Sync + ' static > ;
176
+
177
+ #[ inline]
178
+ fn poll_frame (
179
+ self : Pin < & mut Self > ,
180
+ cx : & mut task:: Context < ' _ > ,
181
+ ) -> Poll < Option < Result < Frame < Self :: Data > , Self :: Error > > > {
182
+ let inner_body = unsafe { self . map_unchecked_mut ( |b| & mut b. 0 ) } ;
183
+ inner_body. poll_frame ( cx)
184
+ }
185
+
186
+ #[ inline]
187
+ fn is_end_stream ( & self ) -> bool {
188
+ self . 0 . is_end_stream ( )
189
+ }
190
+
191
+ #[ inline]
192
+ fn size_hint ( & self ) -> hyper:: body:: SizeHint {
193
+ self . 0 . size_hint ( )
194
+ }
195
+ }
197
196
}
198
197
199
198
/// Methods to make working with responses from the [`HttpClient`] trait easier.
0 commit comments