Skip to main content

Module resolver

Module resolver 

Source
Expand description

Port of internal/variables/resolver.go.

Structs§

ResolverLookup
Adapts a &dyn Resolver to Lookup, since both traits share the exact lookup(&self, name: &str) -> Option<String> signature. Needed at the config↔variables module boundary: variables::expand::expand_map and expand_definition take &dyn Lookup, but config::caproni’s loader only has a Box<dyn Resolver> to offer them. A thin wrapper struct is used rather than impl Lookup for dyn Resolver, because Rust’s dyn-to- dyn coercion only applies to supertrait upcasting, not an arbitrary blanket impl relating two unrelated traits.

Traits§

Lookup
Resolves a variable name to its value. Matches variables.Lookup in the Go original (used by expand.go’s Lookup function type).
Resolver
Resolves variable names to string values. Immutable after construction and safe for concurrent use, once the eventual implementation lands (the Go original documents this contract on the Resolver interface).

Functions§

new_resolver
Resolves all predefined, tool-version, and static variables up front and returns an immutable Resolver. Precedence, highest first: static variables, predefined variables, tool versions, then (via expand) the process environment.