Skip to main content

ApplyConfig

Struct ApplyConfig 

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

Frozen apply-time configuration: install root, target platform, ignore flags, the Vfs backing, observer, and checkpoint sink.

ApplyConfig is the configuration half of the apply API. It owns everything that should be settled before an apply starts; the runtime half — open file handles, scratch buffers, per-chunk progress — lives on ApplySession.

§Construction

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

use zipatch_rs::{ApplyConfig, Platform};

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

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

§Pluggable filesystem

Defaults to StdFs. Override with ApplyConfig::with_vfs to swap in InMemoryFs (for tests / previews) or any custom Vfs backing.

§Running a patch

The high-level drivers — ApplyConfig::apply_patch and ApplyConfig::resume_apply_patch — consume the config, materialise an ApplySession internally, run the patch end-to-end, and drop the session on completion.

§Threading

ApplyObserver, CheckpointSink, and Vfs all carry Send + Sync supertrait bounds, so an ApplyConfig can be constructed on one thread and shipped to a worker for the actual apply.

Implementations§

Source§

impl ApplyConfig

Source

pub fn apply_patch<R: Read>(self, reader: ZiPatchReader<R>) -> ApplyResult<()>

Iterate every chunk in reader and apply each one against a freshly materialised ApplySession.

Convenience wrapper around ApplyConfig::into_session followed by ApplySession::apply_patch; the session is dropped on return.

See ApplySession::apply_patch for the full error contract.

Source

pub fn resume_apply_patch<R: Read + Seek>( self, reader: ZiPatchReader<R>, from: Option<&SequentialCheckpoint>, ) -> ApplyResult<SequentialCheckpoint>

Resume a previously interrupted apply against a freshly materialised ApplySession.

Convenience wrapper around ApplyConfig::into_session followed by ApplySession::resume_apply_patch; the session is dropped on return.

Source§

impl ApplyConfig

Source

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

Create a configuration targeting the given game install directory.

Defaults: platform is Platform::Win32, both ignore-flags are off, vfs is StdFs, observer is NoopObserver, checkpoint sink is NoopCheckpointSink.

Source

pub fn max_cached_fds(&self) -> usize

Returns the configured cap on the open-file-handle cache.

Source

pub fn buffer_capacity(&self) -> usize

Returns the configured per-handle write buffer capacity, in bytes.

Source

pub fn game_path(&self) -> &Path

Returns the game installation directory.

Source

pub fn platform(&self) -> Platform

Returns the configured target platform.

Source

pub fn ignore_missing(&self) -> bool

Returns the configured ignore_missing flag.

Source

pub fn ignore_old_mismatch(&self) -> bool

Returns the configured ignore_old_mismatch flag.

Source

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

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

A [crate::chunk::sqpk::SqpkTargetInfo] chunk encountered during apply overrides this value on the active ApplySession.

Source

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

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

Source

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

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

Source

pub fn with_vfs(self, vfs: impl Vfs + 'static) -> Self

Install a Vfs implementation. Defaults to StdFs.

Swap in InMemoryFs for tests, dry-run previews, or sandboxed environments where the apply must not touch the host filesystem.

Source

pub fn with_observer(self, observer: impl ApplyObserver + 'static) -> Self

Install an ApplyObserver for progress reporting and cancellation.

Source

pub fn with_cancel_token(self, token: CancelToken) -> Self

Install a CancelToken the apply driver polls between chunks (and inside long-running SQPK AddFile block loops) to abort cleanly.

Hold a clone on whichever thread initiates cancellation (typically a UI handler) and pass the original here. The driver checks both the token and any installed ApplyObserver::should_cancel at every cancel point; either source aborts the apply with ApplyError::Cancelled.

Consumers that only want cancellation do not need to implement ApplyObserver at all.

Source

pub fn with_checkpoint_sink(self, sink: impl CheckpointSink + 'static) -> Self

Install a CheckpointSink to receive apply-time checkpoints.

§Panics

Panics if the sink reports CheckpointPolicy::FsyncEveryN with n == 0.

Source

pub fn with_max_cached_fds(self, n: usize) -> Self

Set the maximum number of writable file handles cached by the ApplySession. When the cache reaches this size and a new path is requested, every cached handle is flushed and dropped before the new one is inserted.

Defaults to DEFAULT_MAX_CACHED_FDS (256). Lower this for hosts with tight FD limits; raise it for high-throughput appliers writing to many distinct SqPack files.

§Panics

Panics if n is zero — a zero-sized cache would force eviction on every open and is a programming error.

Source

pub fn with_buffer_capacity(self, bytes: usize) -> Self

Set the per-handle std::io::BufWriter capacity, in bytes, wrapped around every cached Vfs handle.

Defaults to DEFAULT_BUFFER_CAPACITY (64 KiB). Raise it for high-throughput batch appliers; lower it to reduce per-handle memory when many handles are cached concurrently.

§Panics

Panics if bytes is zero — a zero-sized buffer defeats the purpose of wrapping the handle and is a programming error.

Source

pub fn into_session(self) -> ApplySession

Consume this config and materialise a fresh ApplySession.

Follows the into_X convention: same configuration data, handed off to the type that owns the per-apply runtime state.

Trait Implementations§

Source§

impl Debug for ApplyConfig

Source§

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

Formats the value using the given formatter. Read more

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

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
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