File tree Expand file tree Collapse file tree 2 files changed +30
-0
lines changed Expand file tree Collapse file tree 2 files changed +30
-0
lines changed Original file line number Diff line number Diff line change @@ -224,6 +224,16 @@ impl From<Vec<u8>> for Body {
224
224
}
225
225
}
226
226
227
+ impl < ' a > From < & ' a [ u8 ] > for Body {
228
+ fn from ( b : & ' a [ u8 ] ) -> Self {
229
+ Self {
230
+ length : Some ( b. len ( ) ) ,
231
+ reader : Box :: new ( io:: Cursor :: new ( b. to_owned ( ) ) ) ,
232
+ mime : mime:: BYTE_STREAM ,
233
+ }
234
+ }
235
+ }
236
+
227
237
impl From < ( ) > for Body {
228
238
fn from ( _: ( ) ) -> Self {
229
239
Self :: empty ( )
Original file line number Diff line number Diff line change @@ -497,6 +497,12 @@ impl From<Response> for Body {
497
497
}
498
498
}
499
499
500
+ impl From < ( ) > for Response {
501
+ fn from ( _: ( ) ) -> Self {
502
+ Response :: new ( StatusCode :: NoContent )
503
+ }
504
+ }
505
+
500
506
impl From < String > for Response {
501
507
fn from ( s : String ) -> Self {
502
508
let mut res = Response :: new ( StatusCode :: Ok ) ;
@@ -521,6 +527,20 @@ impl From<Vec<u8>> for Response {
521
527
}
522
528
}
523
529
530
+ impl < ' a > From < & ' a [ u8 ] > for Response {
531
+ fn from ( b : & ' a [ u8 ] ) -> Self {
532
+ let mut res = Response :: new ( StatusCode :: Ok ) ;
533
+ res. set_body ( b) ;
534
+ res
535
+ }
536
+ }
537
+
538
+ impl From < StatusCode > for Response {
539
+ fn from ( s : StatusCode ) -> Self {
540
+ Response :: new ( s)
541
+ }
542
+ }
543
+
524
544
impl IntoIterator for Response {
525
545
type Item = ( HeaderName , Vec < HeaderValue > ) ;
526
546
type IntoIter = headers:: IntoIter ;
You can’t perform that action at this time.
0 commit comments