pub struct Documents { /* private fields */ }Expand description
documents: a filtered, read-only view over a fixed set of named text
documents.
Granting documents never grants filesystem access. A host names exactly
which documents exist; there is no way to reach a path this module was not
built to expose, so a grant of documents is narrow authority, never
ambient access to a directory.
Implementations§
Source§impl Documents
impl Documents
Sourcepub fn in_memory(documents: BTreeMap<String, String>) -> Self
pub fn in_memory(documents: BTreeMap<String, String>) -> Self
A fake implementation backed by an in-memory map, for tests.
Sourcepub fn rooted(root: PathBuf) -> Self
pub fn rooted(root: PathBuf) -> Self
Reads <root>/<name>.txt for a document named name.
name must be a single plain path component: empty names, ., ..,
and names containing /, \, or a NUL byte are all rejected before
the filesystem is touched. This keeps the capability narrow: a grant
of documents can only ever reach the fixed set of .txt files under
root, never an arbitrary path via traversal or an absolute path.