@@ -723,6 +723,43 @@ impl From<InvalidAddress> for Error {
723
723
}
724
724
}
725
725
726
+ #[ cfg( feature = "bluetoothd" ) ]
727
+ impl From < Error > for std:: io:: Error {
728
+ fn from ( err : Error ) -> Self {
729
+ use std:: io:: ErrorKind as E ;
730
+ let kind = match err. kind {
731
+ ErrorKind :: AlreadyConnected => E :: AlreadyExists ,
732
+ ErrorKind :: AlreadyExists => E :: AlreadyExists ,
733
+ ErrorKind :: AuthenticationCanceled => E :: PermissionDenied ,
734
+ ErrorKind :: AuthenticationFailed => E :: PermissionDenied ,
735
+ ErrorKind :: AuthenticationRejected => E :: PermissionDenied ,
736
+ ErrorKind :: AuthenticationTimeout => E :: PermissionDenied ,
737
+ ErrorKind :: ConnectionAttemptFailed => E :: ConnectionRefused ,
738
+ ErrorKind :: DoesNotExist => E :: NotFound ,
739
+ ErrorKind :: Failed => E :: Other ,
740
+ ErrorKind :: InProgress => E :: Other ,
741
+ ErrorKind :: InvalidArguments => E :: InvalidInput ,
742
+ ErrorKind :: InvalidLength => E :: InvalidData ,
743
+ ErrorKind :: NotAvailable => E :: NotFound ,
744
+ ErrorKind :: NotAuthorized => E :: PermissionDenied ,
745
+ ErrorKind :: NotReady => E :: Other ,
746
+ ErrorKind :: NotSupported => E :: Unsupported ,
747
+ ErrorKind :: NotPermitted => E :: PermissionDenied ,
748
+ ErrorKind :: InvalidOffset => E :: InvalidInput ,
749
+ ErrorKind :: InvalidAddress ( _) => E :: InvalidInput ,
750
+ ErrorKind :: InvalidName ( _) => E :: InvalidInput ,
751
+ ErrorKind :: ServicesUnresolved => E :: Other ,
752
+ ErrorKind :: NotRegistered => E :: Other ,
753
+ ErrorKind :: NotificationSessionStopped => E :: ConnectionReset ,
754
+ ErrorKind :: IndicationUnconfirmed => E :: TimedOut ,
755
+ ErrorKind :: NotFound => E :: NotFound ,
756
+ ErrorKind :: Internal ( InternalErrorKind :: Io ( err) ) => err,
757
+ ErrorKind :: Internal ( _) => E :: Other ,
758
+ } ;
759
+ std:: io:: Error :: new ( kind, err)
760
+ }
761
+ }
762
+
726
763
#[ cfg( all( feature = "bluetoothd" , feature = "serde" ) ) ]
727
764
mod io_errorkind_serde {
728
765
pub fn serialize < S > ( _kind : & std:: io:: ErrorKind , ser : S ) -> Result < S :: Ok , S :: Error >
0 commit comments