pub trait Source:
Debug
+ Send
+ Sync {
// Required methods
fn kind(&self) -> SourceKind;
fn probe(&self) -> Result<Option<Probe>, Error>;
}Expand description
A single identity source.
Sources are composed into a crate::Resolver. The resolver walks them
in order and uses the first one that yields a Probe; sources that
have nothing to contribute (file missing, feature disabled, wrong
platform) return Ok(None) and are skipped.
Implementations must be inexpensive to construct — the resolver may instantiate them in advance — but probing may perform I/O or spawn a subprocess.
Required Methods§
Sourcefn kind(&self) -> SourceKind
fn kind(&self) -> SourceKind
Provenance label for this source. Shown in error messages and the
resolved crate::HostId.
Sourcefn probe(&self) -> Result<Option<Probe>, Error>
fn probe(&self) -> Result<Option<Probe>, Error>
Attempt to produce a raw identifier.
Ok(Some(probe))— a usable identifier was foundOk(None)— this source had nothing to offer; the resolver continues to the next oneErr(_)— a hard failure the caller should know about (permission denied, malformed registry entry, sentinel value likeuninitialized)
§Errors
Returns Error when the source encounters a hard failure such as
an I/O error other than “not found” / “permission denied”, a
platform-tool failure, or a sentinel value that indicates an
uninitialized identifier.