1 | use crate::{ |
2 | message::{Header, Message}, |
3 | names::ErrorName, |
4 | Result, |
5 | }; |
6 | |
7 | /// A trait that needs to be implemented by error types to be returned from D-Bus methods. |
8 | /// |
9 | /// Typically, you'd use the [`crate::fdo::Error`] since that covers quite a lot of failures but |
10 | /// occasionally you might find yourself needing to use a custom error type. You'll need to |
11 | /// implement this trait for your error type. The easiest way to achieve that is to make use of the |
12 | /// [`DBusError` macro][dm]. |
13 | /// |
14 | /// [dm]: derive.DBusError.html |
15 | pub trait DBusError { |
16 | /// Generate an error reply message for the given method call. |
17 | fn create_reply(&self, msg: &Header<'_>) -> Result<Message>; |
18 | |
19 | // The name of the error. |
20 | // |
21 | // Every D-Bus error must have a name. See [`ErrorName`] for more information. |
22 | fn name(&self) -> ErrorName<'_>; |
23 | |
24 | // The optional description for the error. |
25 | fn description(&self) -> Option<&str>; |
26 | } |
27 | |