11use crate :: IoctlFlags ;
2- use failure :: Fail ;
2+ use thiserror :: Error ;
33use nix:: errno:: Errno ;
44
55pub type Result < T > = std:: result:: Result < T , Error > ;
@@ -10,38 +10,38 @@ pub type Result<T> = std::result::Result<T, Error>;
1010/// [`userfaultfd(2)`](http://man7.org/linux/man-pages/man2/userfaultfd.2.html) and
1111/// [`ioctl_userfaultfd(2)`](http://man7.org/linux/man-pages/man2/ioctl_userfaultfd.2.html) for more
1212/// details on how to interpret these errors.
13- #[ derive( Debug , Fail ) ]
13+ #[ derive( Debug , Error ) ]
1414pub enum Error {
1515 /// Copy ioctl failure with `errno` value.
16- #[ fail ( display = "copy failed: {}" , 0 ) ]
16+ #[ error ( "Copy failed" ) ]
1717 CopyFailed ( Errno ) ,
1818
1919 /// Failure to read a full `uffd_msg` struct from the underlying file descriptor.
20- #[ fail ( display = "incomplete uffd_msg; read only {}/{} bytes", read , expected ) ]
20+ #[ error ( "Incomplete uffd_msg; read only {read }/{expected } bytes") ]
2121 IncompleteMsg { read : usize , expected : usize } ,
2222
2323 /// Generic system error.
24- #[ fail ( display = "system error: {}" , 0 ) ]
25- SystemError ( nix:: Error ) ,
24+ #[ error ( "System error" ) ]
25+ SystemError ( # [ source ] nix:: Error ) ,
2626
2727 /// End-of-file was read from the underlying file descriptor.
28- #[ fail ( display = "EOF when reading file descriptor" ) ]
28+ #[ error ( "EOF when reading file descriptor" ) ]
2929 ReadEof ,
3030
3131 /// An unrecognized event code was found in a `uffd_msg` struct.
32- #[ fail ( display = "unrecognized event in uffd_msg: {}" , 0 ) ]
32+ #[ error ( "Unrecognized event in uffd_msg: {0}" ) ]
3333 UnrecognizedEvent ( u8 ) ,
3434
3535 /// An unrecognized ioctl bit was set in the result of API initialization or registration.
36- #[ fail ( display = "unrecognized ioctl flags: {}" , 0 ) ]
36+ #[ error ( "Unrecognized ioctl flags: {0}" ) ]
3737 UnrecognizedIoctls ( u64 ) ,
3838
3939 /// Requested ioctls were not available when initializing the API.
40- #[ fail ( display = "requested ioctls unsupported; supported: {:?}", 0 ) ]
40+ #[ error ( "Requested ioctls unsupported; supported: {0 :?}") ]
4141 UnsupportedIoctls ( IoctlFlags ) ,
4242
4343 /// Zeropage ioctl failure with `errno` value.
44- #[ fail ( display = "zeropage failed: {}" , 0 ) ]
44+ #[ error ( "Zeropage failed: {0}" ) ]
4545 ZeropageFailed ( Errno ) ,
4646}
4747
0 commit comments