Skip to main content

ChunkDestination

Enum ChunkDestination 

Source
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

§layer: &'pkg str

The layer the chunk belongs to.

§wad: Option<&'pkg str>

The WAD the chunk belongs to, if it belongs to one.

§path: &'pkg str

The chunk’s stored path, relative to its WAD.

§

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.

Fields

§file_name: &'pkg str

The table’s file name, e.g. game.hashes.txt.

Implementations§

Source§

impl ChunkDestination<'_>

Source

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>

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<'pkg> Copy for ChunkDestination<'pkg>

Source§

impl<'pkg> Debug for ChunkDestination<'pkg>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Display for ChunkDestination<'_>

Writes what compose returns.

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'pkg> PartialEq for ChunkDestination<'pkg>

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl<'pkg> StructuralPartialEq for ChunkDestination<'pkg>

Auto Trait Implementations§

§

impl<'pkg> Freeze for ChunkDestination<'pkg>

§

impl<'pkg> RefUnwindSafe for ChunkDestination<'pkg>

§

impl<'pkg> Send for ChunkDestination<'pkg>

§

impl<'pkg> Sync for ChunkDestination<'pkg>

§

impl<'pkg> Unpin for ChunkDestination<'pkg>

§

impl<'pkg> UnsafeUnpin for ChunkDestination<'pkg>

§

impl<'pkg> UnwindSafe for ChunkDestination<'pkg>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> CustomError for T
where T: Display + Debug + Send + Sync + 'static,

Source§

fn as_any(&self) -> &(dyn Any + Sync + Send + 'static)

Source§

fn as_any_mut(&mut self) -> &mut (dyn Any + Sync + Send + 'static)

Source§

fn as_box_any(self: Box<T>) -> Box<dyn Any + Sync + Send>

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.