use std::fmt;
#[derive(Debug)]
pub(crate) struct ResponderDropped;
impl fmt::Display for ResponderDropped {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "pairing responder receiver was dropped")
}
}
impl std::error::Error for ResponderDropped {}
#[derive(thiserror::Error, Debug)]
pub enum Error {
#[error("dbus error: {0}")]
Dbus(#[from] zbus::Error),
#[error("cannot initialize bluetooth service")]
ServiceInitialization(#[source] Box<dyn std::error::Error + Send + Sync>),
#[error("cannot register bluetooth agent")]
AgentRegistration(#[source] Box<dyn std::error::Error + Send + Sync>),
#[error("cannot {operation} on adapter")]
AdapterOperation {
operation: &'static str,
#[source]
source: zbus::Error,
},
#[error("cannot {operation}: no primary adapter available")]
NoPrimaryAdapter {
operation: &'static str,
},
#[error("cannot discover bluetooth objects")]
Discovery(#[source] zbus::fdo::Error),
#[error("cannot start monitoring: no cancellation token configured")]
NoCancellationToken,
#[error("cannot provide {request_type}: no {request_type} request is pending")]
NoPendingRequest {
request_type: &'static str,
},
#[error("cannot provide {request_type}: no responder available")]
NoResponder {
request_type: &'static str,
},
#[error("cannot send {request_type} response")]
ResponderSend {
request_type: &'static str,
#[source]
source: Box<dyn std::error::Error + Send + Sync>,
},
}