1use std::fmt;
3
4#[derive(Debug)]
6pub enum Error {
7 Create(std::io::Error),
9 AddSeals(std::io::Error),
11 GetSeals(std::io::Error),
13}
14
15impl std::error::Error for Error {
16 fn source(&self) -> Option<&(dyn std::error::Error + 'static)> {
17 match self {
18 Error::Create(e) | Error::AddSeals(e) | Error::GetSeals(e) => Some(e),
19 }
20 }
21}
22
23impl fmt::Display for Error {
24 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
25 f.write_str(match self {
26 Error::Create(_) => "cannot create a memfd",
27 Error::AddSeals(_) => "cannot add seals to the memfd",
28 Error::GetSeals(_) => "cannot read seals for a memfd",
29 })
30 }
31}
32
33#[cfg(test)]
34#[test]
35fn error_send_sync() {
36 fn assert_error<E: std::error::Error + Send + Sync + fmt::Display + fmt::Debug + 'static>() {}
37 assert_error::<Error>();
38}