devices/usb/backend/fido_backend/
error.rs

1// Copyright 2024 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
5use std::io::Error as IOError;
6
7use remain::sorted;
8use thiserror::Error;
9
10use crate::utils::Error as UtilsError;
11
12#[sorted]
13#[derive(Error, Debug)]
14pub enum Error {
15    #[error("Failed to arm {name} timer: {error:#}")]
16    CannotArmPollTimer { name: String, error: base::Error },
17    #[error("Failed to clear {name} timer: {error:#}")]
18    CannotClearPollTimer { name: String, error: base::Error },
19    #[error("Cannot convert the u2f init packet from bytes")]
20    CannotConvertInitPacketFromBytes,
21    #[error("Cannot create the poll timer")]
22    CannotCreatePollTimer(base::Error),
23    #[error("Pending fido transfer reference has been lost.")]
24    FidoTransferLost,
25    #[error("The fido device is in an inconsistent state")]
26    InconsistentFidoDeviceState,
27    #[error("Invalid data buffer size")]
28    InvalidDataBufferSize,
29    #[error("The given hidraw device is not a security key")]
30    InvalidHidrawDevice,
31    #[error("The u2f init packet is invalid")]
32    InvalidInitPacket,
33    #[error("The u2f init packet contains invalid data size for the nonce")]
34    InvalidNonceSize,
35    #[error("Pending packet queue is full and cannot process more host packets")]
36    PendingInQueueFull,
37    #[error("Failed to read packet from hidraw device")]
38    ReadHidrawDevice(IOError),
39    #[error("Cannot start fido device queue")]
40    StartAsyncFidoQueue(UtilsError),
41    #[error("Unsupported TransferBuffer type")]
42    UnsupportedTransferBufferType,
43    #[error("Failed to wait context on poll thread")]
44    WaitContextFailed(anyhow::Error),
45    #[error("Failed to write to hidraw device")]
46    WriteHidrawDevice(IOError),
47}
48
49pub type Result<T> = std::result::Result<T, Error>;