bt_rfcomm/frame/
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::FrameTypeMarker;
8use crate::Role;
9
10/// Errors associated with parsing an RFCOMM Frame.
11#[derive(Error, Debug)]
12pub enum FrameParseError {
13    #[error("Provided buffer is too small")]
14    BufferTooSmall,
15    #[error("Invalid buffer size provided. Expected: {}, Actual: {}", .0, .1)]
16    InvalidBufferLength(usize, usize),
17    #[error("FCS check for the Frame failed")]
18    FCSCheckFailed,
19    #[error("Invalid Role when parsing frame: {:?}", .0)]
20    InvalidRole(Role),
21    #[error("DLCI ({:?}) is invalid", .0)]
22    InvalidDLCI(u8),
23    #[error("Frame is invalid")]
24    InvalidFrame,
25    #[error("Frame type not supported before mux startup: {:?})", .0)]
26    InvalidFrameBeforeMuxStartup(FrameTypeMarker),
27    #[error("Frame type is unsupported")]
28    UnsupportedFrameType,
29    #[error("Mux Command type {} is unsupported", .0)]
30    UnsupportedMuxCommandType(u8),
31    #[error("Value is out of range")]
32    OutOfRange,
33    #[error(transparent)]
34    Other(#[from] anyhow::Error),
35}