@@ -259,8 +259,7 @@ impl RequestSpec {
259259
260260 pub async fn retrieve ( self ) -> Result < ( ) > {
261261 let ( req, _mime_type, rsocket) = self . preflight ( ) ?;
262- rsocket. fire_and_forget ( req) . await ;
263- Ok ( ( ) )
262+ rsocket. fire_and_forget ( req) . await
264263 }
265264
266265 pub async fn retrieve_mono ( self ) -> Unpacker {
@@ -364,10 +363,16 @@ fn do_unmarshal<T>(mime_type: &MimeType, raw: &Bytes) -> Result<Option<T>>
364363where
365364 T : Sized + DeserializeOwned ,
366365{
367- // TODO: support more mime types
368- match * mime_type {
369- MimeType :: APPLICATION_JSON => Ok ( Some ( unmarshal ( misc:: json ( ) , & raw . as_ref ( ) ) ?) ) ,
370- MimeType :: APPLICATION_CBOR => Ok ( Some ( unmarshal ( misc:: cbor ( ) , & raw . as_ref ( ) ) ?) ) ,
366+ match mime_type. as_u8 ( ) {
367+ Some ( code) => {
368+ if code == MimeType :: APPLICATION_JSON . as_u8 ( ) . unwrap ( ) {
369+ Ok ( Some ( unmarshal ( misc:: json ( ) , & raw . as_ref ( ) ) ?) )
370+ } else if code == MimeType :: APPLICATION_CBOR . as_u8 ( ) . unwrap ( ) {
371+ Ok ( Some ( unmarshal ( misc:: cbor ( ) , & raw . as_ref ( ) ) ?) )
372+ } else {
373+ Err ( RSocketError :: WithDescription ( "unsupported mime type!" . into ( ) ) . into ( ) )
374+ }
375+ }
371376 _ => Err ( RSocketError :: WithDescription ( "unsupported mime type!" . into ( ) ) . into ( ) ) ,
372377 }
373378}
@@ -376,10 +381,16 @@ fn do_marshal<T>(mime_type: &MimeType, data: &T) -> Result<Vec<u8>>
376381where
377382 T : Sized + Serialize ,
378383{
379- // TODO: support more mime types
380- match * mime_type {
381- MimeType :: APPLICATION_JSON => marshal ( misc:: json ( ) , data) ,
382- MimeType :: APPLICATION_CBOR => marshal ( misc:: cbor ( ) , data) ,
384+ match mime_type. as_u8 ( ) {
385+ Some ( code) => {
386+ if code == MimeType :: APPLICATION_JSON . as_u8 ( ) . unwrap ( ) {
387+ marshal ( misc:: json ( ) , data)
388+ } else if code == MimeType :: APPLICATION_CBOR . as_u8 ( ) . unwrap ( ) {
389+ marshal ( misc:: cbor ( ) , data)
390+ } else {
391+ Err ( RSocketError :: WithDescription ( "unsupported mime type!" . into ( ) ) . into ( ) )
392+ }
393+ }
383394 _ => Err ( RSocketError :: WithDescription ( "unsupported mime type!" . into ( ) ) . into ( ) ) ,
384395 }
385396}
0 commit comments