pub enum ChunkDestination<'pkg> {
Content {
layer: &'pkg str,
wad: Option<&'pkg str>,
path: &'pkg str,
},
Root(&'static str),
Hashtable {
file_name: &'pkg str,
},
}Expand description
Where one chunk lands when it is unpacked.
The two variants are the two roots an unpack writes into. A package
extracted to look at puts both under one directory - that is what
Display spells - but a mod project keeps its content under
content/ and its readme, license and thumbnail at its own root, so the
distinction has to survive the answer.
Not #[non_exhaustive], for the reason ltk_mod_project’s Fantome
counterpart is not: a caller sizing an unpack has to account for every kind
of destination, and wants a compile error rather than a silent miss if one
is added.
Variants§
Content
Layer content, at {layer}/{wad}/{path} beneath the directory the
content is unpacked into.
A chunk’s stored path is relative to the WAD it belongs to, so the WAD
name comes back as a directory or a repack cannot tell which WAD the
chunk was in. A chunk belonging to no WAD has wad: None and sits at
the layer root; a chunk several WADs share is planned once under each.
Fields
Root(&'static str)
A meta chunk, written at the root of the unpack under this name:
README.md, LICENSE or thumbnail.webp.
The package stores these under _meta_/, but that is not where they
land: the names here are the ones a mod project keeps them at, and the
ones ltk_mod_project’s ProjectPacker picks back up from a project
directory, so extract -> pack is a round trip.
The metadata chunk is not planned at all: it is msgpack, its project-level
form is mod.config.json, and that is not a byte-for-byte transform of
it. Read it with Modpkg::load_metadata instead.
Hashtable
A hashtable chunk, written at hashes/{file_name}.
The package stores it under _meta_/hashes/, and hashes/ beside
the content is where a mod project keeps its tables - the same
agreement by which Root’s names are the ones a
project uses. file_name borrows from the package’s own path table.
Planned by where the chunk is stored, not by what the metadata
declares: like the plan itself, this answers “where would this chunk
land on disk” and never produces a table for lookup. The
manifest-gated read is Modpkg::load_hashtables.
Implementations§
Source§impl ChunkDestination<'_>
impl ChunkDestination<'_>
Sourcepub fn compose(&self) -> String
pub fn compose(&self) -> String
The path this chunk lands at, relative to the root it is written into.
{layer}/{wad}/{path} for layer content and the bare file name for a
root file, separated by / as a chunk path is. Which root it is
relative to is the variant’s business: a caller writing the two to two
directories - as a mod project does - matches first and joins this onto
the one it picked. A caller writing both to one, as
ModpkgExtractor::extract_all
does, joins it onto that.
The same string Display writes, named for what a
caller does with it.
Trait Implementations§
Source§impl<'pkg> Clone for ChunkDestination<'pkg>
impl<'pkg> Clone for ChunkDestination<'pkg>
impl<'pkg> Copy for ChunkDestination<'pkg>
Source§impl<'pkg> Debug for ChunkDestination<'pkg>
impl<'pkg> Debug for ChunkDestination<'pkg>
Source§impl Display for ChunkDestination<'_>
Writes what compose returns.
impl Display for ChunkDestination<'_>
Writes what compose returns.