1use core::fmt;
2
3#[derive(Debug, Clone, Copy, PartialEq, Eq)]
7#[non_exhaustive]
8pub enum Error {
9 InvalidFieldName,
11 InvalidTypeName,
13 InvalidInterfaceName,
15}
16
17impl fmt::Display for Error {
18 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
19 let msg = match self {
20 Self::InvalidFieldName => "Invalid Varlink field name",
21 Self::InvalidTypeName => "Invalid Varlink type name",
22 Self::InvalidInterfaceName => "Invalid Varlink interface name",
23 };
24
25 f.write_str(msg)
26 }
27}
28
29impl core::error::Error for Error {}
30
31#[cfg(test)]
32mod tests {
33 use super::*;
34 use alloc::string::ToString;
35
36 #[test]
37 fn display() {
38 assert_eq!(
39 Error::InvalidFieldName.to_string(),
40 "Invalid Varlink field name"
41 );
42 assert_eq!(
43 Error::InvalidTypeName.to_string(),
44 "Invalid Varlink type name"
45 );
46 assert_eq!(
47 Error::InvalidInterfaceName.to_string(),
48 "Invalid Varlink interface name"
49 );
50 }
51}