summaryrefslogtreecommitdiff
path: root/system/gd/rust/stack/src/hci/error.rs
blob: 4ab44e31ce724e25b249e57f3df3081177689788 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
//! Defines the Result type and HCI errors

use futures::channel::oneshot;
use std::fmt::Debug;
use thiserror::Error;
use tokio::sync::mpsc::error::SendError;
use tokio::sync::oneshot::error::RecvError;

/// Result type
pub type Result<T> = std::result::Result<T, Box<dyn std::error::Error + Send + Sync>>;

/// HCI errors
#[derive(Error, Debug)]
pub enum HciError<T: Debug + 'static> {
    /// Error when sending on a bounded channel
    #[error("Error sending: {0}")]
    BoundedSendError(#[from] SendError<T>),
    /// Error when sending on a oneshot channel
    #[error("Error sending: {0}")]
    OneshotSendError(#[from] oneshot::Canceled),
    /// Error receiving from a channel
    #[error("Error receiving: {0}")]
    ChannelRecvError(#[from] RecvError),
}