• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2019 The ChromiumOS Authors
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 use std::io;
6 use std::num;
7 
8 use base::IoctlNr;
9 use remain::sorted;
10 use thiserror::Error;
11 
12 #[sorted]
13 #[derive(Error, Debug)]
14 pub enum Error {
15     #[error("parsing descriptors failed")]
16     DescriptorParse,
17     #[error("reading descriptors from device failed: {0}")]
18     DescriptorRead(io::Error),
19     #[error("File::try_clone() failed: {0}")]
20     FdCloneFailed(io::Error),
21     #[error("invalid actual_length in URB: {0}")]
22     InvalidActualLength(num::TryFromIntError),
23     #[error("invalid transfer buffer length: {0}")]
24     InvalidBufferLength(num::TryFromIntError),
25     #[error("USB ioctl 0x{0:x} failed: {1}")]
26     IoctlFailed(IoctlNr, base::Error),
27     #[error("Device has been removed")]
28     NoDevice,
29     #[error("Requested descriptor not found")]
30     NoSuchDescriptor,
31     #[error("Rc::get_mut failed")]
32     RcGetMutFailed,
33     #[error("Rc::try_unwrap failed")]
34     RcUnwrapFailed,
35     #[error("attempted to cancel already-completed transfer")]
36     TransferAlreadyCompleted,
37 }
38 
39 pub type Result<T> = std::result::Result<T, Error>;
40