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