1use std::fmt;
2
3#[derive(Debug)]
4pub(crate) struct ResponderDropped;
5
6impl fmt::Display for ResponderDropped {
7 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
8 write!(f, "pairing responder receiver was dropped")
9 }
10}
11
12impl std::error::Error for ResponderDropped {}
13
14#[derive(thiserror::Error, Debug)]
16pub enum Error {
17 #[error("dbus error: {0}")]
19 Dbus(#[from] zbus::Error),
20
21 #[error("cannot initialize bluetooth service")]
23 ServiceInitialization(#[source] Box<dyn std::error::Error + Send + Sync>),
24
25 #[error("cannot register bluetooth agent")]
27 AgentRegistration(#[source] Box<dyn std::error::Error + Send + Sync>),
28
29 #[error("cannot {operation} on adapter")]
31 AdapterOperation {
32 operation: &'static str,
34 #[source]
36 source: zbus::Error,
37 },
38
39 #[error("cannot {operation}: no primary adapter available")]
41 NoPrimaryAdapter {
42 operation: &'static str,
44 },
45
46 #[error("cannot discover bluetooth objects")]
48 Discovery(#[source] zbus::fdo::Error),
49
50 #[error("cannot start monitoring: no cancellation token configured")]
52 NoCancellationToken,
53
54 #[error("cannot provide {request_type}: no {request_type} request is pending")]
56 NoPendingRequest {
57 request_type: &'static str,
59 },
60
61 #[error("cannot provide {request_type}: no responder available")]
63 NoResponder {
64 request_type: &'static str,
66 },
67
68 #[error("cannot send {request_type} response")]
70 ResponderSend {
71 request_type: &'static str,
73 #[source]
75 source: Box<dyn std::error::Error + Send + Sync>,
76 },
77}