88//!
99//! ```
1010//! # use eh1 as embedded_hal;
11- //! use std::io::ErrorKind;
1211//!
13- //! use embedded_hal::digital::{InputPin, OutputPin, StatefulOutputPin};
12+ //! use embedded_hal::digital::{InputPin, OutputPin, StatefulOutputPin, ErrorKind };
1413//! use embedded_hal_mock::eh1::{
1514//! digital::{Mock as PinMock, State as PinState, Transaction as PinTransaction},
16- //! MockError,
1715//! };
1816//!
19- //! let err = MockError::Io( ErrorKind::NotConnected) ;
17+ //! let err = ErrorKind::Other ;
2018//!
2119//! // Configure expectations
2220//! let expectations = [
5250//! ```
5351
5452use eh1 as embedded_hal;
55- use embedded_hal:: digital:: { ErrorType , InputPin , OutputPin , StatefulOutputPin } ;
53+ use embedded_hal:: digital:: { ErrorKind , ErrorType , InputPin , OutputPin , StatefulOutputPin } ;
5654
57- use crate :: { common:: Generic , eh1 :: error :: MockError } ;
55+ use crate :: common:: Generic ;
5856
5957/// MockPin transaction
6058#[ derive( PartialEq , Eq , Clone , Debug ) ]
@@ -64,7 +62,7 @@ pub struct Transaction {
6462 /// An optional error return value for a transaction. This is in addition
6563 /// to `kind` to allow validation that the transaction kind is correct
6664 /// prior to returning the error.
67- err : Option < MockError > ,
65+ err : Option < ErrorKind > ,
6866}
6967
7068#[ derive( PartialEq , Eq , Copy , Clone , Debug ) ]
@@ -149,7 +147,7 @@ impl Transaction {
149147 /// Note that this can only be used for methods which actually return a
150148 /// [`Result`]; trying to invoke this for others will lead to an assertion
151149 /// error!
152- pub fn with_error ( mut self , error : MockError ) -> Self {
150+ pub fn with_error ( mut self , error : ErrorKind ) -> Self {
153151 assert ! (
154152 self . kind. supports_errors( ) ,
155153 "the transaction kind supports errors"
@@ -202,7 +200,7 @@ impl TransactionKind {
202200pub type Mock = Generic < Transaction > ;
203201
204202impl ErrorType for Mock {
205- type Error = MockError ;
203+ type Error = ErrorKind ;
206204}
207205
208206/// Single digital push-pull output pin
@@ -458,17 +456,15 @@ impl embedded_hal_async::digital::Wait for Mock {
458456
459457#[ cfg( test) ]
460458mod test {
461- use std:: io:: ErrorKind ;
462459 #[ cfg( feature = "embedded-hal-async" ) ]
463460 use std:: time:: Duration ;
464461
465462 use eh1 as embedded_hal;
466- use embedded_hal:: digital:: { InputPin , OutputPin , StatefulOutputPin } ;
463+ use embedded_hal:: digital:: { ErrorKind , InputPin , OutputPin , StatefulOutputPin } ;
467464 #[ cfg( feature = "embedded-hal-async" ) ]
468465 use tokio:: time:: timeout;
469466
470467 use super :: {
471- super :: error:: MockError ,
472468 TransactionKind :: { Get , GetState , Set , Toggle } ,
473469 * ,
474470 } ;
@@ -480,7 +476,7 @@ mod test {
480476 Transaction :: new ( Get ( State :: High ) ) ,
481477 Transaction :: new ( Get ( State :: Low ) ) ,
482478 Transaction :: new ( Get ( State :: Low ) ) ,
483- Transaction :: new ( Get ( State :: High ) ) . with_error ( MockError :: Io ( ErrorKind :: NotConnected ) ) ,
479+ Transaction :: new ( Get ( State :: High ) ) . with_error ( ErrorKind :: Other ) ,
484480 ] ;
485481 let mut pin = Mock :: new ( & expectations) ;
486482
@@ -499,7 +495,7 @@ mod test {
499495 let expectations = [
500496 Transaction :: new ( Set ( State :: High ) ) ,
501497 Transaction :: new ( Set ( State :: Low ) ) ,
502- Transaction :: new ( Set ( State :: High ) ) . with_error ( MockError :: Io ( ErrorKind :: NotConnected ) ) ,
498+ Transaction :: new ( Set ( State :: High ) ) . with_error ( ErrorKind :: Other ) ,
503499 ] ;
504500 let mut pin = Mock :: new ( & expectations) ;
505501
@@ -520,8 +516,8 @@ mod test {
520516 Transaction :: get_state ( State :: High ) ,
521517 Transaction :: get_state ( State :: High ) ,
522518 Transaction :: toggle ( ) ,
523- Transaction :: get_state ( State :: Low ) . with_error ( MockError :: Io ( ErrorKind :: NotConnected ) ) ,
524- Transaction :: toggle ( ) . with_error ( MockError :: Io ( ErrorKind :: NotConnected ) ) ,
519+ Transaction :: get_state ( State :: Low ) . with_error ( ErrorKind :: Other ) ,
520+ Transaction :: toggle ( ) . with_error ( ErrorKind :: Other ) ,
525521 ] ;
526522 let mut pin = Mock :: new ( & expectations) ;
527523
@@ -549,7 +545,7 @@ mod test {
549545 Transaction :: new ( TransactionKind :: WaitForState ( State :: High ) ) ,
550546 Transaction :: new ( TransactionKind :: WaitForState ( State :: Low ) ) ,
551547 Transaction :: new ( TransactionKind :: WaitForState ( State :: High ) )
552- . with_error ( MockError :: Io ( ErrorKind :: NotConnected ) ) ,
548+ . with_error ( ErrorKind :: Other ) ,
553549 ] ;
554550 let mut pin = Mock :: new ( & expectations) ;
555551
@@ -586,7 +582,7 @@ mod test {
586582 Transaction :: new ( TransactionKind :: WaitForStateForever ( State :: High ) ) ,
587583 Transaction :: new ( TransactionKind :: WaitForStateForever ( State :: Low ) ) ,
588584 Transaction :: new ( TransactionKind :: WaitForStateForever ( State :: High ) )
589- . with_error ( MockError :: Io ( ErrorKind :: NotConnected ) ) ,
585+ . with_error ( ErrorKind :: Other ) ,
590586 ] ;
591587 let mut pin = Mock :: new ( & expectations) ;
592588
@@ -616,7 +612,7 @@ mod test {
616612 Transaction :: new ( TransactionKind :: WaitForEdge ( Edge :: Falling ) ) ,
617613 Transaction :: new ( TransactionKind :: WaitForEdge ( Edge :: Any ) ) ,
618614 Transaction :: new ( TransactionKind :: WaitForEdge ( Edge :: Rising ) )
619- . with_error ( MockError :: Io ( ErrorKind :: NotConnected ) ) ,
615+ . with_error ( ErrorKind :: Other ) ,
620616 ] ;
621617 let mut pin = Mock :: new ( & expectations) ;
622618
@@ -641,7 +637,7 @@ mod test {
641637 Transaction :: new ( TransactionKind :: WaitForEdgeForever ( Edge :: Falling ) ) ,
642638 Transaction :: new ( TransactionKind :: WaitForEdgeForever ( Edge :: Any ) ) ,
643639 Transaction :: new ( TransactionKind :: WaitForEdgeForever ( Edge :: Rising ) )
644- . with_error ( MockError :: Io ( ErrorKind :: NotConnected ) ) ,
640+ . with_error ( ErrorKind :: Other ) ,
645641 ] ;
646642 let mut pin = Mock :: new ( & expectations) ;
647643
0 commit comments