#[non_exhaustive]pub enum Error {
NoSource {
tried: String,
},
Uninitialized {
source_kind: SourceKind,
path: PathBuf,
},
Io {
source_kind: SourceKind,
path: PathBuf,
source: Error,
},
Malformed {
source_kind: SourceKind,
reason: String,
},
Platform {
source_kind: SourceKind,
reason: String,
},
}Expand description
Errors returned by crate::Resolver::resolve.
Every variant except Error::NoSource carries the SourceKind
that produced it, so logs and error messages unambiguously identify
which source failed. Error::source_kind exposes the field
uniformly across variants.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
NoSource
Every configured source was tried and none produced a usable identity.
Uninitialized
A source file was present but contained the systemd uninitialized
sentinel. The caller should not treat this as a valid identity — every
host in this state would hash to the same UUID.
Fields
source_kind: SourceKindWhich source produced the error.
Io
I/O failure while reading a source file. Command-spawn failures are
reported as Error::Platform instead — this variant’s path
field is always a real filesystem path.
Fields
source_kind: SourceKindWhich source produced the error.
Malformed
A source returned a value that is not a well-formed identifier (empty after trimming, wrong shape, invalid UTF-8, …).
Fields
source_kind: SourceKindWhich source produced the error.
Platform
Platform-specific lookup failed (registry query, syscall, ioreg, cloud metadata contract violation, …).
Fields
source_kind: SourceKindWhich source produced the error.
Implementations§
Source§impl Error
impl Error
Sourcepub fn source_kind(&self) -> Option<SourceKind>
pub fn source_kind(&self) -> Option<SourceKind>
The source that produced this error, if the variant carries one.
Returns None only for Error::NoSource, which reports that
every source was tried and none produced a value — that error
doesn’t belong to any single source.
Sourcepub fn is_recoverable(&self) -> bool
pub fn is_recoverable(&self) -> bool
Whether this error is reasonable for the caller to recover from at runtime (log a warning, mint a per-run placeholder UUID, etc.) rather than treat as a fatal configuration problem.
Error::NoSource→true. No source produced a value, but the crate is behaving correctly; the caller’s chain simply doesn’t match the environment. Apps often handle this by falling back to their own ID scheme.- All other variants →
false. They indicate a concrete fault (sentinel, I/O failure, malformed source value, platform-tool failure) that won’t fix itself on retry; the caller should surface them to the operator.
This classification is a guideline, not a hard contract. A
particular deployment might reasonably treat an Io error on
/etc/machine-id as recoverable (keep going with the next
source) — the method exists to give the common case a one-liner,
not to remove the caller’s judgement.
Trait Implementations§
Source§impl Error for Error
impl Error for Error
Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
use the Display impl or to_string()