mirror of
https://chromium.googlesource.com/crosvm/crosvm
synced 2025-02-06 10:32:10 +00:00
6b19695c81
For now, this crate simply re-exports all of sys_util, but it will be updated to provide new interfaces when needed. This is the first step to making crosvm not directly depend on sys_util, so that we can make the interface changes we need without fear of negatively affecting (i.e. completely breaking) other usages within chromeos. BUG=b:162363783 TEST=./build_test Change-Id: I7d0aa3d8a1f66af1c7fee8fd649723ef17027150 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2325168 Tested-by: Michael Hoyle <mikehoyle@google.com> Tested-by: kokoro <noreply+kokoro@google.com> Commit-Queue: Michael Hoyle <mikehoyle@google.com> Reviewed-by: Daniel Verkamp <dverkamp@chromium.org> Reviewed-by: Zach Reizner <zachr@chromium.org>
51 lines
1.7 KiB
Rust
51 lines
1.7 KiB
Rust
// Copyright 2019 The Chromium OS Authors. All rights reserved.
|
|
// Use of this source code is governed by a BSD-style license that can be
|
|
// found in the LICENSE file.
|
|
|
|
use base::IoctlNr;
|
|
use remain::sorted;
|
|
use std::fmt::{self, Display};
|
|
use std::io;
|
|
use std::num;
|
|
|
|
#[sorted]
|
|
#[derive(Debug)]
|
|
pub enum Error {
|
|
DescriptorParse,
|
|
DescriptorRead(io::Error),
|
|
FdCloneFailed(io::Error),
|
|
InvalidActualLength(num::TryFromIntError),
|
|
InvalidBufferLength(num::TryFromIntError),
|
|
IoctlFailed(IoctlNr, base::Error),
|
|
NoDevice,
|
|
NoSuchDescriptor,
|
|
RcGetMutFailed,
|
|
RcUnwrapFailed,
|
|
TransferAlreadyCompleted,
|
|
}
|
|
|
|
impl Display for Error {
|
|
#[remain::check]
|
|
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
|
use self::Error::*;
|
|
|
|
#[sorted]
|
|
match self {
|
|
DescriptorParse => write!(f, "parsing descriptors failed"),
|
|
DescriptorRead(e) => write!(f, "reading descriptors from device failed: {}", e),
|
|
FdCloneFailed(e) => write!(f, "File::try_clone() failed: {}", e),
|
|
InvalidActualLength(e) => write!(f, "invalid actual_length in URB: {}", e),
|
|
InvalidBufferLength(e) => write!(f, "invalid transfer buffer length: {}", e),
|
|
IoctlFailed(nr, e) => write!(f, "USB ioctl 0x{:x} failed: {}", nr, e),
|
|
NoDevice => write!(f, "Device has been removed"),
|
|
NoSuchDescriptor => write!(f, "Requested descriptor not found"),
|
|
RcGetMutFailed => write!(f, "Rc::get_mut failed"),
|
|
RcUnwrapFailed => write!(f, "Rc::try_unwrap failed"),
|
|
TransferAlreadyCompleted => write!(f, "attempted to cancel already-completed transfer"),
|
|
}
|
|
}
|
|
}
|
|
|
|
pub type Result<T> = std::result::Result<T, Error>;
|
|
|
|
impl std::error::Error for Error {}
|