1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
// Copyright (c) 2026 Mike Grier
// Split from error_code.rs at 4fbcb343.
//! An error's code, read without the ring crate (DI-D-39), and the faults the Windows path
//! reports with it (DI-D-50).
use io;
use Arc;
use ;
use IoRingErrorExt;
/// The source every fault the Windows path reports names: the I/O ring beneath it.
pub const WINDOWS_IORING: &str = "windows-ioring";
/// A fault the Windows path reports for `error`: the I/O ring's, with the code it carries.
pub
/// The code `error` carries, if it carries one.
///
/// Every failure the I/O ring reports answers `Some`, because the ring reports each as an
/// `HRESULT`; the Windows path reads it so into each [`IoFault`] it relays. An error carrying a
/// Win32 code, as `io::Error::from_raw_os_error` makes, answers it wrapped as
/// `HRESULT_FROM_WIN32` wraps it. An error with neither, such as one a consumer's provider made
/// from a message, answers `None`. A code read from a `FailureCause::Provider` error is the
/// provider's own, relayed, not one dioring captured (DI-D-47).
///
/// ```
/// use win_durable_ioring::error_code_of;
///
/// // ERROR_IO_DEVICE, as std reports a Win32 error.
/// let code = error_code_of(&std::io::Error::from_raw_os_error(1117)).unwrap();
/// assert_eq!(code.win32(), Some(1117));
/// assert_eq!(code.hresult().cast_unsigned(), 0x8007_045D);
/// ```