File tree 1 file changed +27
-0
lines changed
1 file changed +27
-0
lines changed Original file line number Diff line number Diff line change @@ -73,6 +73,33 @@ pub enum Error {
73
73
HostAddressNotAvailable ,
74
74
}
75
75
76
+ impl PartialEq for Error {
77
+ fn eq ( & self , other : & Self ) -> bool {
78
+ match ( self , other) {
79
+ ( Error :: InvalidGuestAddress ( left) , Error :: InvalidGuestAddress ( right) ) => left == right,
80
+ ( Error :: InvalidBackendAddress , Error :: InvalidBackendAddress ) => true ,
81
+ ( Error :: HostAddressNotAvailable , Error :: HostAddressNotAvailable ) => true ,
82
+ (
83
+ Error :: PartialBuffer {
84
+ expected : left_expected,
85
+ completed : left_completed,
86
+ } ,
87
+ Error :: PartialBuffer {
88
+ expected : right_expected,
89
+ completed : right_completed,
90
+ } ,
91
+ ) => left_expected == right_expected && left_completed == right_completed,
92
+ ( Error :: IOError ( left) , Error :: IOError ( right) ) => {
93
+ // error.kind should be enough to assert equallity because each error
94
+ // has the kind field set and the OS error numbers can be converted
95
+ // to ErrorKind through `sys::decode_error_kind`.
96
+ left. kind ( ) == right. kind ( )
97
+ }
98
+ _ => false ,
99
+ }
100
+ }
101
+ }
102
+
76
103
impl From < volatile_memory:: Error > for Error {
77
104
fn from ( e : volatile_memory:: Error ) -> Self {
78
105
match e {
You can’t perform that action at this time.
0 commit comments