bt_rfcomm/
error.rs

1// Copyright 2021 The Fuchsia Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5use thiserror::Error;
6
7use crate::frame::FrameParseError;
8use crate::{Role, DLCI};
9
10/// Errors that occur during the usage of the RFCOMM library.
11#[derive(Error, Debug)]
12pub enum Error {
13    #[error("Error parsing frame: {:?}", .0)]
14    Frame(FrameParseError),
15    #[error("Invalid DLCI: {:?}", .0)]
16    InvalidDLCI(DLCI),
17    #[error("Invalid role: {:?}", .0)]
18    InvalidRole(Role),
19    #[error(transparent)]
20    Other(#[from] anyhow::Error),
21}
22
23impl From<FrameParseError> for Error {
24    fn from(src: FrameParseError) -> Self {
25        Self::Frame(src)
26    }
27}