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