use fidl_fuchsia_bluetooth_bredr as bredr;
use thiserror::Error;
#[derive(Error, Debug)]
pub enum Error {
#[error("Error adding search to already terminated ProfileClient")]
AlreadyTerminated,
#[error("Search Result stream ended in error: {:?}", source)]
SearchResult { source: Box<dyn std::error::Error + Send + Sync> },
#[error("Connection Receiver stream ended in error: {:?}", source)]
ConnectionReceiver { source: Box<dyn std::error::Error + Send + Sync> },
#[error("Advertisement ended prematurely: {:?}", result)]
Advertisement { result: bredr::ProfileAdvertiseResult },
#[error("FIDL Error occurred: {:?}", source)]
Fidl { source: fidl::Error },
}
impl Error {
pub fn connection_receiver<E>(e: E) -> Self
where
E: Into<Box<dyn std::error::Error + Send + Sync>>,
{
Self::ConnectionReceiver { source: e.into() }
}
pub fn search_result<E>(e: E) -> Self
where
E: Into<Box<dyn std::error::Error + Send + Sync>>,
{
Self::SearchResult { source: e.into() }
}
}
impl From<fidl::Error> for Error {
fn from(source: fidl::Error) -> Self {
Self::Fidl { source }
}
}