pub trait SourceTree {
// Required methods
fn list(&self) -> Result<Vec<String>>;
fn read(&self, key: &str) -> Result<String>;
}Expand description
A source of .brink files: enumerate what exists under a root (held by
the implementation since construction — see the module docs),
and read any key, whether or not enumeration returned it.
See the module docs for the full contract. Implementations must
return list() results sorted by key, regardless of what order the
underlying storage (filesystem, git tree, in-memory map) happens to
iterate in.
Required Methods§
Sourcefn list(&self) -> Result<Vec<String>>
fn list(&self) -> Result<Vec<String>>
Enumerate every source key under the implementation’s own root, sorted deterministically by key.
Sourcefn read(&self, key: &str) -> Result<String>
fn read(&self, key: &str) -> Result<String>
Read the source text for key.
key is usually one list previously returned, but
callers may also probe speculative candidate keys list never
returned (see the module docs — e.g. an ancestor-directory
walk-up probing for a config file). Implementations MUST return
io::ErrorKind::NotFound, and no other error kind, when key does
not exist — speculative callers rely on that kind to distinguish “not
here, keep probing” from a real I/O failure.
read carries no key-kind scoping even when list does (see the
module docs “policy asymmetry” section) — whether a key is
native source or not plays no role in whether read serves it. A
per-key overlay unrelated to nativeness (e.g. a moved/deleted-key
guard) may still legally refuse a specific existing key.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".