@@ -162,7 +162,7 @@ impl http_body::Host for ComponentCtx {
162162 h : Resource < http_body:: Body > ,
163163 max_len : u64 ,
164164 cursor : u32 ,
165- ) -> Result < ( String , Option < u32 > ) , types :: Error > {
165+ ) -> Result < ( String , Option < u32 > ) , http_body :: TrailerError > {
166166 let h = h. into ( ) ;
167167
168168 // Read operations are not allowed on streaming bodies.
@@ -172,7 +172,7 @@ impl http_body::Host for ComponentCtx {
172172
173173 let body = self . session_mut ( ) . body_mut ( h) ?;
174174 if !body. trailers_ready {
175- return Err ( Error :: Again . into ( ) ) ;
175+ return Err ( http_body :: TrailerError :: NotAvailableYet ) ;
176176 }
177177
178178 let trailers = & body. trailers ;
@@ -186,7 +186,7 @@ impl http_body::Host for ComponentCtx {
186186 h : Resource < http_body:: Body > ,
187187 name : String ,
188188 max_len : u64 ,
189- ) -> Result < Option < Vec < u8 > > , types :: Error > {
189+ ) -> Result < Option < Vec < u8 > > , http_body :: TrailerError > {
190190 let h = h. into ( ) ;
191191
192192 // Read operations are not allowed on streaming bodies.
@@ -196,7 +196,7 @@ impl http_body::Host for ComponentCtx {
196196
197197 let body = self . session_mut ( ) . body_mut ( h) ?;
198198 if !body. trailers_ready {
199- return Err ( Error :: Again . into ( ) ) ;
199+ return Err ( http_body :: TrailerError :: NotAvailableYet ) ;
200200 }
201201
202202 let trailers = & mut body. trailers ;
@@ -230,17 +230,17 @@ impl http_body::Host for ComponentCtx {
230230 name : String ,
231231 max_len : u64 ,
232232 cursor : u32 ,
233- ) -> Result < ( Vec < u8 > , Option < u32 > ) , types :: Error > {
233+ ) -> Result < ( Vec < u8 > , Option < u32 > ) , http_body :: TrailerError > {
234234 let h = h. into ( ) ;
235235
236236 // Read operations are not allowed on streaming bodies.
237237 if self . session ( ) . is_streaming_body ( h) {
238238 return Err ( Error :: InvalidArgument . into ( ) ) ;
239239 }
240240
241- let body = self . session_mut ( ) . body_mut ( h) ? ;
241+ let body = self . session_mut ( ) . body_mut ( h) . unwrap ( ) ;
242242 if !body. trailers_ready {
243- return Err ( Error :: Again . into ( ) ) ;
243+ return Err ( http_body :: TrailerError :: NotAvailableYet ) ;
244244 }
245245
246246 let trailers = & mut body. trailers ;
@@ -249,3 +249,9 @@ impl http_body::Host for ComponentCtx {
249249 Ok ( ( buf, next) )
250250 }
251251}
252+
253+ impl < T : Into < types:: Error > > From < T > for http_body:: TrailerError {
254+ fn from ( err : T ) -> Self {
255+ Self :: Error ( err. into ( ) )
256+ }
257+ }
0 commit comments