File tree Expand file tree Collapse file tree 1 file changed +14
-0
lines changed Expand file tree Collapse file tree 1 file changed +14
-0
lines changed Original file line number Diff line number Diff line change 11
11
//! This is done by emulating an UART serial port.
12
12
13
13
use std:: collections:: VecDeque ;
14
+ use std:: error:: Error as StdError ;
15
+ use std:: fmt;
14
16
use std:: io:: { self , Write } ;
15
17
use std:: result:: Result ;
16
18
use std:: sync:: Arc ;
@@ -289,6 +291,18 @@ pub enum Error<E> {
289
291
FullFifo ,
290
292
}
291
293
294
+ impl < E : fmt:: Display > fmt:: Display for Error < E > {
295
+ fn fmt ( & self , f : & mut fmt:: Formatter ) -> fmt:: Result {
296
+ match self {
297
+ Error :: Trigger ( e) => write ! ( f, "Failed to trigger interrupt: {}" , e) ,
298
+ Error :: IOError ( e) => write ! ( f, "Couldn't write/flush to the given destination: {}" , e) ,
299
+ Error :: FullFifo => write ! ( f, "No space left in FIFO" ) ,
300
+ }
301
+ }
302
+ }
303
+
304
+ impl < E : StdError > StdError for Error < E > { }
305
+
292
306
impl < T : Trigger , W : Write > Serial < T , NoEvents , W > {
293
307
/// Creates a new `Serial` instance which writes the guest's output to
294
308
/// `out` and uses `trigger` object to notify the driver about new
You can’t perform that action at this time.
0 commit comments