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