Expand description
varchain is an async-only, zero-runtime-dependency crate for looking up variables
from a chain of sources.
§Core Concepts
- Resolved: The result of a lookup from a single source (
FoundorPass). - Source: A trait for objects that can resolve a key to a
Resolvedvalue. - Scope: A collection of sources queried in order.
- lookup: The primary function to query a key from a
Scope.
§Example
use varchain::{Scope, Resolved, Source};
use std::collections::HashMap;
let mut map = HashMap::new();
map.insert("key1".to_string(), "value1".to_string());
let scope = Scope::new()
.push(map); // HashMap impls Source
assert_eq!(scope.lookup("key1").await, Some("value1".to_string()));
assert_eq!(scope.lookup("key2").await, None);Structs§
- Scope
- A chain of sources to be queried in order.
Enums§
Traits§
- Source
- A source capable of looking up a variable by key.
Functions§
- lookup
- Looks up a key in the given scope.
Type Aliases§
- Source
Future - A future returned by a source lookup.