profile_client/
error.rs
1use fidl_fuchsia_bluetooth_bredr as bredr;
6use thiserror::Error;
7
8#[derive(Error, Debug)]
9pub enum Error {
10 #[error("Error adding search to already terminated ProfileClient")]
12 AlreadyTerminated,
13 #[error("Search Result stream ended in error: {:?}", source)]
15 SearchResult { source: Box<dyn std::error::Error + Send + Sync> },
16 #[error("Connection Receiver stream ended in error: {:?}", source)]
18 ConnectionReceiver { source: Box<dyn std::error::Error + Send + Sync> },
19 #[error("Advertisement ended prematurely: {:?}", result)]
22 Advertisement { result: bredr::ProfileAdvertiseResult },
23 #[error("FIDL Error occurred: {:?}", source)]
25 Fidl { source: fidl::Error },
26}
27
28impl Error {
29 pub fn connection_receiver<E>(e: E) -> Self
30 where
31 E: Into<Box<dyn std::error::Error + Send + Sync>>,
32 {
33 Self::ConnectionReceiver { source: e.into() }
34 }
35
36 pub fn search_result<E>(e: E) -> Self
37 where
38 E: Into<Box<dyn std::error::Error + Send + Sync>>,
39 {
40 Self::SearchResult { source: e.into() }
41 }
42}
43
44impl From<fidl::Error> for Error {
45 fn from(source: fidl::Error) -> Self {
46 Self::Fidl { source }
47 }
48}