pub enum Keys {
One(String),
Several(Vec<String>),
Prefix(String),
}Expand description
What a source reads: one file, several named ones, or a directory.
Builder::path takes one, and a bare &str or String is
Keys::one — so the single-file spelling every caller already wrote keeps
working unchanged.
§Why this store can do it and the key-value ones cannot
Every store in this family folds several keys into one document, and every
other one has to say out loud that the set is not read at one instant:
S3 issues one GetObject per key, Vault one read per path, Consul one
request per key. A deployment writing two of them is a document that never
existed.
A git fetch resolves one commit, and a commit has one tree. Every
path below is read out of that tree, so the set is atomic with no
transaction, no listing race and no second round trip — the guarantee comes
from git’s object model rather than from anything this crate arranges. That
is also why a multi-file git source can be watched, which no other store
here allows: see GitSource::watch.
Variants§
One(String)
One file, whose contents are the whole document.
Handed to the loader byte for byte — never parsed and re-rendered, so comments and key order survive and no format feature is needed that was not needed before.
Several(Vec<String>)
Several named files, merged in the order given — later wins.
The rule a list of .file(..) calls already teaches: the caller wrote
the list, so the list is the precedence. Tables merge deeply and arrays
are replaced whole.
Prefix(String)
Every file under a directory, merged as disjoint sections.
A caller naming a directory is not expressing an order — a tree lists its entries in the order git sorted them, which is nobody’s precedence — so two files under it supplying the same path is a deployment bug, and reported as one rather than resolved.
A directory, not a string prefix, because a git tree has
directories: Keys::prefix("services/api") reads services/api/db.yaml
and does not read services/api-old.yaml. The walk is recursive, an
empty string is the repository root, and every file found has to parse —
so point it at a directory that holds configuration and nothing else.
Implementations§
Trait Implementations§
impl Eq for Keys
impl StructuralPartialEq for Keys
Auto Trait Implementations§
impl Freeze for Keys
impl RefUnwindSafe for Keys
impl Send for Keys
impl Sync for Keys
impl Unpin for Keys
impl UnsafeUnpin for Keys
impl UnwindSafe for Keys
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.