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.
45//! Definition of possible errors in this crate.
67/// Possible errors in the crate.
8#[derive(thiserror::Error, Debug)]
9#[allow(missing_docs)]
10pub enum Error {
11#[error(transparent)]
12Fidl(#[from] fidl::Error),
13#[error("unknown RxFlags({0}) set by driver")]
14RxFlags(u32),
15#[error("unknown FrameType({0}) set by driver")]
16FrameType(u8),
17#[error("invalid config: {0}")]
18Config(String),
19#[error("too many descriptors are chained ({0}), at most 4 are allowed")]
20LargeChain(usize),
21#[error("index out of bound {0} > {1}")]
22Index(usize, usize),
23#[error("failed to pad buffer to {0}, capacity {1}")]
24Pad(usize, usize),
25#[error("cannot allocate a buffer to meet the device requirement")]
26TxLength,
27#[error("failed to open session {0}: {1}")]
28Open(String, zx::Status),
29#[error("failed to create VMO {0}: {1}")]
30Vmo(&'static str, zx::Status),
31#[error("failed to {0} fifo {1}: {2}")]
32Fifo(&'static str, &'static str, zx::Status),
33#[error("failed to get size of {0} VMO: {1}")]
34VmoSize(&'static str, zx::Status),
35#[error("failed to map {0} VMO: {1}")]
36Map(&'static str, zx::Status),
37#[error("failed to validate netdev::DeviceInfo")]
38DeviceInfo(#[from] crate::session::DeviceInfoValidationError),
39#[error("failed to validate netdev::PortStatus")]
40PortStatus(#[from] crate::client::PortStatusValidationError),
41#[error("failed to attach port {0:?}: {1}")]
42Attach(crate::Port, zx::Status),
43#[error("failed to detach port {0:?}: {1}")]
44Detach(crate::Port, zx::Status),
45#[error("invalid base port identifier {0}")]
46InvalidPortId(u8),
47#[error("buffer is too small: {size} < {offset} + {length}")]
48TooSmall { size: usize, offset: usize, length: usize },
49#[error("received an invalid lease")]
50InvalidLease,
51}
5253/// Common result type for methods in this crate.
54pub type Result<T> = std::result::Result<T, Error>;