pub enum MemberSource {
Zip(Vec<u8>),
Tree {
root: PathBuf,
mapping: BTreeMap<String, PathBuf>,
},
}Expand description
The member-content source abstraction (13-02 Task 3): the proven
v1.0 member engine (crate::client::resources, zip-bytes-only)
speaks EITHER a gateway export zip OR a checked-out directory
tree, with ONE implementation behind both — 13-03’s checkout and
13-06’s status compare build on this without touching proven code.
MemberSource::Zipdelegates VERBATIM to the existing resources.rs functions — descriptor-normalized enumeration/ read/hash semantics stay single-source (no engine function is copied here).MemberSource::Treereads a checked-out tree through the RECORDED mapping with the SAME member-hash semantics: a member’s hash is identical from either source for identical bytes (equivalence pinned by test). Aresource.jsonmember hashes its normalized descriptor exactly as the zip side does — the same helpers (resources::normalize_descriptor, [resources::fnv1a], [resources::FOLDER_DESCRIPTOR]), never a fork.
Tree strictness (pinned here): the tree is MANIFEST-SCOPED. A mapped member missing from disk, or a local file not in the mapping, is an error from the source — 13-06’s status handles unknown files at the action layer, where a human-facing verdict belongs.
Variants§
Zip(Vec<u8>)
A gateway project-export zip’s raw bytes.
Tree
A checked-out directory tree rooted at root, addressed
through the recorded checkout mapping (gateway member →
local path — build_mapping’s output, stored in the
manifest by 13-03).
Implementations§
Source§impl MemberSource
impl MemberSource
Sourcepub fn members(&self) -> Result<Vec<String>, CoreError>
pub fn members(&self) -> Result<Vec<String>, CoreError>
Every resource member’s user path. Zip: the export walk in
member order (the proven resources::resource_members
semantics — project.json, directory entries, and
non-resources-shaped members skipped). Tree: the recorded
mapping’s keys, sorted.
Sourcepub fn read(&self, user_path: &str) -> Result<Vec<u8>, CoreError>
pub fn read(&self, user_path: &str) -> Result<Vec<u8>, CoreError>
One member’s bytes, verbatim. Zip: the proven
resources::read_member (missing → not_found). Tree:
fs::read at the mapped local path — a member outside the
recorded mapping or a missing file is invalid_input naming
the member (the tree is manifest-scoped, so “unmapped” is a
caller/manifest contract break, not a 404-shaped lookup miss).
Sourcepub fn member_hashes(&self) -> Result<BTreeMap<String, u64>, CoreError>
pub fn member_hashes(&self) -> Result<BTreeMap<String, u64>, CoreError>
User path → FNV-1a digest for every member — the SAME
descriptor rule both sides: a basename resource.json hashes
its resources::normalize_descriptor output (the
lastModification volatility guard), everything else hashes raw
bytes. Zip: the proven resources::member_hashes. Tree:
reads the mapped files after a strictness walk — a mapped
member missing from disk, or an on-disk file absent from the
mapping, is invalid_input (manifest-scoped tree).