Skip to main content

ModpkgExtractor

Struct ModpkgExtractor 

Source
pub struct ModpkgExtractor<'modpkg, TSource: Read + Seek> { /* private fields */ }
Expand description

Extractor for ModPkg archives.

This struct provides functionality to extract chunks from a ModPkg archive to a specified directory, organized by layers.

Implementations§

Source§

impl<'modpkg, TSource: Read + Seek> ModpkgExtractor<'modpkg, TSource>

Source

pub fn new(modpkg: &'modpkg mut Modpkg<TSource>) -> Self

Create a new extractor for the given ModPkg.

Source

pub fn extract_all( &mut self, output_dir: impl AsRef<Path>, ) -> Result<(), ModpkgError>

Extract all chunks from the ModPkg to the specified output directory.

Content chunks are organized by layer, with each layer having its own subdirectory, in layer-name order. Meta chunks belong to no layer and are written to the output root under the names a mod project uses for them (see extract_meta).

This is a package unpacked to look at, not a mod project: a project keeps its layers under content/ and is read from a mod.config.json that no chunk holds. Use ltk_mod_project’s ModpkgImporter to write one of those, or call extract_layer and extract_meta with the two directories yourself.

Source

pub fn layer_names(&self) -> Vec<String>

The package’s layer names, in the order extract_all walks them.

Sorted, because the header’s layer table is hashed and two extractions of one package must not report their layers in two different orders. A layer the package declares but holds no chunk for is still listed.

Source

pub fn extract_layer( &mut self, layer: &str, output_dir: impl AsRef<Path>, ) -> Result<(), ModpkgError>

Extract one layer’s chunks into output_dir/{layer}/.

A chunk’s stored path is relative to the WAD it belongs to, so it is written under a directory of that WAD’s name: {layer}/{wad}/{path}. That is the layout a mod project holds its content in, and the one ModpkgBuilder reads WAD membership back out of, so extract -> pack keeps every chunk in the WAD it came from. A chunk belonging to no WAD is written at {layer}/{path}, and a chunk several WADs share is written once under each of them.

A layer the package does not hold writes nothing rather than failing: a project may declare a layer whose content it has yet to add.

Source

pub fn extract_meta( &mut self, output_dir: impl AsRef<Path>, ) -> Result<(), ModpkgError>

Write the meta chunks that have a project-level file form to output_dir.

That is the readme, the license text and the thumbnail, under the names a mod project keeps them at its root, and the hashtables, under hashes/. Chunks without such a form (the metadata chunk, which is msgpack rather than a project file) are skipped rather than dumped under _meta_/; read it with Modpkg::load_metadata instead.

Source

pub fn extract_chunk( &mut self, chunk: &ModpkgChunk, output_dir: impl AsRef<Path>, ) -> Result<PathBuf, ModpkgError>

Extract a specific chunk to the specified directory.

Source

pub fn extract_chunk_by_path( &mut self, path: &str, layer: &str, output_dir: impl AsRef<Path>, ) -> Result<PathBuf, ModpkgError>

Extract a specific chunk by its path and layer name.

Auto Trait Implementations§

§

impl<'modpkg, TSource> !UnwindSafe for ModpkgExtractor<'modpkg, TSource>

§

impl<'modpkg, TSource> Freeze for ModpkgExtractor<'modpkg, TSource>
where &'modpkg mut Modpkg<TSource>: Freeze,

§

impl<'modpkg, TSource> RefUnwindSafe for ModpkgExtractor<'modpkg, TSource>
where &'modpkg mut Modpkg<TSource>: RefUnwindSafe,

§

impl<'modpkg, TSource> Send for ModpkgExtractor<'modpkg, TSource>
where &'modpkg mut Modpkg<TSource>: Send,

§

impl<'modpkg, TSource> Sync for ModpkgExtractor<'modpkg, TSource>
where &'modpkg mut Modpkg<TSource>: Sync,

§

impl<'modpkg, TSource> Unpin for ModpkgExtractor<'modpkg, TSource>
where &'modpkg mut Modpkg<TSource>: Unpin,

§

impl<'modpkg, TSource> UnsafeUnpin for ModpkgExtractor<'modpkg, TSource>
where &'modpkg mut Modpkg<TSource>: UnsafeUnpin,

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