Skip to main content

Source

Trait Source 

Source
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§

Source

fn kind(&self) -> SourceKind

Provenance label for this source. Shown in error messages and the resolved crate::HostId.

Source

fn probe(&self) -> Result<Option<Probe>, Error>

Attempt to produce a raw identifier.

  • Ok(Some(probe)) — a usable identifier was found
  • Ok(None) — this source had nothing to offer; the resolver continues to the next one
  • Err(_) — a hard failure the caller should know about (permission denied, malformed registry entry, sentinel value like uninitialized)
§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.

Implementations on Foreign Types§

Source§

impl<T: Source + ?Sized> Source for Box<T>

Implementors§