xref: /aosp_15_r20/external/crosvm/cros_async/src/sys/windows/error.rs (revision bb4ee6a4ae7042d18b07a98463b9c8b875e44b39)
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 
5 use std::io;
6 
7 #[remain::sorted]
8 #[derive(Debug, thiserror::Error)]
9 pub enum AsyncErrorSys {
10     #[error("An error with a handle executor: {0}")]
11     HandleExecutor(#[from] super::handle_executor::Error),
12     #[error("An error with a handle source: {0}")]
13     HandleSource(#[from] super::handle_source::Error),
14     #[error("An error with a handle source: {0}")]
15     OverlappedSource(#[from] super::overlapped_source::Error),
16     #[cfg(feature = "tokio")]
17     #[error("Tokio source error: {0}")]
18     Tokio(#[from] super::tokio_source::Error),
19 }
20 
21 impl From<AsyncErrorSys> for io::Error {
from(err: AsyncErrorSys) -> Self22     fn from(err: AsyncErrorSys) -> Self {
23         match err {
24             AsyncErrorSys::HandleExecutor(e) => e.into(),
25             AsyncErrorSys::HandleSource(e) => e.into(),
26             AsyncErrorSys::OverlappedSource(e) => e.into(),
27             #[cfg(feature = "tokio")]
28             AsyncErrorSys::Tokio(e) => e.into(),
29         }
30     }
31 }
32