Skip to main content

SourceTree

Trait SourceTree 

Source
pub trait SourceTree {
    // Required methods
    fn list(&self) -> Result<Vec<String>, Error>;
    fn read(&self, key: &str) -> Result<String, Error>;
}
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§

Source

fn list(&self) -> Result<Vec<String>, Error>

Enumerate every source key under the implementation’s own root, sorted deterministically by key.

Source

fn read(&self, key: &str) -> Result<String, Error>

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".

Implementors§