Skip to main content

ApplyContext

Struct ApplyContext 

Source
pub struct ApplyContext { /* private fields */ }
Expand description

Apply-time state: install root, target platform, flag toggles, and the internal file-handle cache used by SQPK writers.

§Construction

Build with ApplyContext::new, then chain the with_* builder methods to override defaults:

use zipatch_rs::{ApplyContext, Platform};

let ctx = ApplyContext::new("/opt/ffxiv/game")
    .with_platform(Platform::Win32)
    .with_ignore_missing(true);

assert_eq!(ctx.game_path().to_str().unwrap(), "/opt/ffxiv/game");
assert_eq!(ctx.platform(), Platform::Win32);
assert!(ctx.ignore_missing());

§Platform mutation

The platform defaults to Platform::Win32. If the patch stream contains a crate::chunk::sqpk::SqpkTargetInfo chunk, applying it overwrites ApplyContext::platform with the platform declared in the chunk. This is the normal case: real FFXIV patches begin with a TargetInfo chunk that pins the platform, so the default is rarely used in practice.

Set the platform explicitly with ApplyContext::with_platform when you know the target in advance or are processing a synthetic patch.

§Flag mutation

ApplyContext::ignore_missing and ApplyContext::ignore_old_mismatch can also be overwritten mid-stream by ApplyOption chunks embedded in the patch file. Set initial values with the with_ignore_* builder methods.

§File-handle cache

Internally, ApplyContext maintains a bounded map of open file handles keyed by absolute path. The cache is an optimisation: a patch that writes many chunks into the same .dat file re-uses a single handle rather than opening and closing the file for every write.

The cache is capped at 256 entries. When that limit is reached and a new path is needed, all entries are evicted at once. Handles are also evicted explicitly before deleting a file (see DeleteFile) and before a RemoveAll bulk operation.

Implementations§

Source§

impl ApplyContext

Source

pub fn new(game_path: impl Into<PathBuf>) -> Self

Create a context targeting the given game install directory.

Defaults: platform is Platform::Win32, both ignore-flags are off.

Use the with_* builder methods to change these defaults before applying the first chunk.

§Example
use zipatch_rs::ApplyContext;

let ctx = ApplyContext::new("/opt/ffxiv/game");
assert_eq!(ctx.game_path().to_str().unwrap(), "/opt/ffxiv/game");
Source

pub fn game_path(&self) -> &Path

Returns the game installation directory.

All file paths produced during apply are relative to this root.

Source

pub fn platform(&self) -> Platform

Returns the current target platform.

This value may change during apply if the patch stream contains a crate::chunk::sqpk::SqpkTargetInfo chunk.

Source

pub fn ignore_missing(&self) -> bool

Returns whether missing files are silently ignored during apply.

When true, operations that target a file that does not exist log a warning instead of returning an error. This flag may be overwritten mid-stream by an ApplyOption chunk.

Source

pub fn ignore_old_mismatch(&self) -> bool

Returns whether old-data mismatches are silently ignored during apply.

When true, apply operations that detect a checksum or data mismatch against the existing on-disk content proceed without error. This flag may be overwritten mid-stream by an ApplyOption chunk.

Source

pub fn with_platform(self, platform: Platform) -> Self

Sets the target platform. Defaults to Platform::Win32.

The platform determines the directory suffix used when resolving SqPack file paths (win32, ps3, or ps4).

Note: a crate::chunk::sqpk::SqpkTargetInfo chunk encountered during apply will override this value.

Source

pub fn with_ignore_missing(self, v: bool) -> Self

Silently ignore missing files instead of returning an error during apply.

When false (the default), any apply operation that cannot find its target file returns crate::ZiPatchError::Io with kind std::io::ErrorKind::NotFound.

When true, those failures are demoted to warn!-level tracing events.

Source

pub fn with_ignore_old_mismatch(self, v: bool) -> Self

Silently ignore old-data mismatches instead of returning an error during apply.

When false (the default), an apply operation that detects that the on-disk data does not match the expected “before” state returns an error.

When true, the mismatch is logged at warn! level and the operation continues.

Auto Trait Implementations§

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> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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 = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more