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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
// SPDX-License-Identifier: MIT OR Apache-2.0
//! Error types for `hypomnesis`.
/// Errors that can occur during a `hypomnesis` measurement.
///
/// `#[non_exhaustive]`: new variants will be added as new backends are introduced
/// (e.g., AMD `ROCm` SMI, Apple Metal). Patch-release-safe.
///
/// # `Display` vs structured fields
///
/// `HypomnesisError`'s `Display` impl is the **default English one-liner** —
/// suitable for logs, library-tier error reporting, and `?`-propagation where
/// the consumer is content with the default rendering. Structured fields
/// ([`Self::DeviceIndexOutOfRange`]'s `index` / `count`, the inner `String` of
/// [`Self::Nvml`] / [`Self::Dxgi`] / [`Self::NvidiaSmi`]) are the **canonical
/// source** for any consumer that wants to:
///
/// - Localize the message to a non-English language.
/// - Restyle for a CLI / GUI / JSON output (column-aligned tables,
/// wrap-aware formatting, JSON keys for the structured pieces).
/// - Apply singular / plural agreement, custom punctuation, or richer
/// formatting (`"have 1 device"` vs the default `"have 1 devices"`,
/// for instance).
///
/// This contract makes `Display` stable for the common case while leaving
/// custom-render consumers free to assemble their own strings without
/// fighting the default. Consumers writing user-facing tools should prefer
/// `match err { HypomnesisError::DeviceIndexOutOfRange { index, count } => ... }`
/// over `format!("{err}")`. Future `Display`-string improvements will avoid
/// adding structural information that the structured fields already expose
/// (so consumers that hand-format from the fields cannot end up
/// double-rendering the count).
/// Result alias for `hypomnesis` operations.
pub type Result<T> = Result;