@@ -34,7 +34,7 @@ pub trait Receivable<'a>: Sized {
3434// ============================================================================
3535
3636/// The ways this API can fail
37- #[ derive( Debug , Copy , Clone , Format ) ]
37+ #[ derive( Debug , Copy , Clone , Format , PartialEq , Eq ) ]
3838pub enum Error {
3939 BadCrc ,
4040 BadLength ,
@@ -45,7 +45,7 @@ pub enum Error {
4545
4646/// The kinds of [`Request`] the *Host* can make to the NBMC
4747#[ repr( u8 ) ]
48- #[ derive( Debug , Copy , Clone , Format ) ]
48+ #[ derive( Debug , Copy , Clone , Format , PartialEq , Eq ) ]
4949pub enum RequestType {
5050 Read = 0xC0 ,
5151 ReadAlt = 0xC1 ,
@@ -57,7 +57,7 @@ pub enum RequestType {
5757
5858/// The NBMC returns this code to indicate whether the previous [`Request`] was
5959/// succesful or not.
60- #[ derive( Debug , Copy , Clone , Format ) ]
60+ #[ derive( Debug , Copy , Clone , Format , PartialEq , Eq ) ]
6161pub enum ResponseResult {
6262 /// The [`Request`] was correctly understood and actioned.
6363 Ok = 0xA0 ,
@@ -85,7 +85,7 @@ pub enum ResponseResult {
8585// ============================================================================
8686
8787/// A *Request* made by the *Host* to the *NBMC*
88- #[ derive( Debug , Clone , Format ) ]
88+ #[ derive( Debug , Clone , Format , PartialEq , Eq ) ]
8989pub struct Request {
9090 pub request_type : RequestType ,
9191 pub register : u8 ,
@@ -94,7 +94,7 @@ pub struct Request {
9494}
9595
9696/// A *Response* sent by the *NBMC* in reply to a [`Request`] from a *Host*
97- #[ derive( Debug , Clone , Format ) ]
97+ #[ derive( Debug , Clone , Format , PartialEq , Eq ) ]
9898pub struct Response < ' a > {
9999 pub result : ResponseResult ,
100100 pub data : & ' a [ u8 ] ,
@@ -103,7 +103,7 @@ pub struct Response<'a> {
103103
104104/// Describes the [semantic version](https://semver.org) of this implementation
105105/// of the NBMC interface.
106- #[ derive( Debug , Copy , Clone , Format ) ]
106+ #[ derive( Debug , Copy , Clone , Format , PartialEq , Eq ) ]
107107pub struct ProtocolVersion {
108108 major : u8 ,
109109 minor : u8 ,
@@ -140,9 +140,9 @@ impl Request {
140140 pub fn new_read ( use_alt : bool , register : u8 , length : u8 ) -> Request {
141141 let mut req = Request {
142142 request_type : if use_alt {
143- RequestType :: Read
144- } else {
145143 RequestType :: ReadAlt
144+ } else {
145+ RequestType :: Read
146146 } ,
147147 register,
148148 length_or_data : length,
@@ -161,9 +161,9 @@ impl Request {
161161 pub fn new_short_write ( use_alt : bool , register : u8 , data : u8 ) -> Request {
162162 let mut req = Request {
163163 request_type : if use_alt {
164- RequestType :: ShortWrite
165- } else {
166164 RequestType :: ShortWriteAlt
165+ } else {
166+ RequestType :: ShortWrite
167167 } ,
168168 register,
169169 length_or_data : data,
@@ -183,9 +183,9 @@ impl Request {
183183 pub fn new_long_write ( use_alt : bool , register : u8 , length : u8 ) -> Request {
184184 let mut req = Request {
185185 request_type : if use_alt {
186- RequestType :: LongWrite
187- } else {
188186 RequestType :: LongWriteAlt
187+ } else {
188+ RequestType :: LongWrite
189189 } ,
190190 register,
191191 length_or_data : length,
@@ -377,21 +377,21 @@ impl ProtocolVersion {
377377 ///
378378 /// // This is compatible.
379379 /// let bmc_a = ProtocolVersion::new(1, 1, 1);
380- /// assert!(bmc_a.is_compatible (&my_version));
380+ /// assert!(bmc_a.is_compatible_with (&my_version));
381381 ///
382382 /// // This is incompatible - patch is too low.
383383 /// let bmc_b = ProtocolVersion::new(1, 0, 0);
384- /// assert!(!bmc_b.is_compatible (&my_version));
384+ /// assert!(!bmc_b.is_compatible_with (&my_version));
385385 ///
386386 /// // This is incompatible - major is too high.
387387 /// let bmc_c = ProtocolVersion::new(2, 0, 0);
388- /// assert!(!bmc_c.is_compatible (&my_version));
388+ /// assert!(!bmc_c.is_compatible_with (&my_version));
389389 ///
390390 /// // This is incompatible - major is too low.
391391 /// let bmc_d = ProtocolVersion::new(0, 1, 0);
392- /// assert!(!bmc_d.is_compatible (&my_version));
392+ /// assert!(!bmc_d.is_compatible_with (&my_version));
393393 /// ```
394- pub const fn is_compatible ( & self , my_version : & ProtocolVersion ) -> bool {
394+ pub const fn is_compatible_with ( & self , my_version : & ProtocolVersion ) -> bool {
395395 if self . major == my_version. major {
396396 if self . minor > my_version. minor {
397397 true
0 commit comments