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
impl ApplyConfig
Sourcepub fn apply_patch<R: Read>(self, reader: ZiPatchReader<R>) -> ApplyResult<()>
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.
Sourcepub fn resume_apply_patch<R: Read + Seek>(
self,
reader: ZiPatchReader<R>,
from: Option<&SequentialCheckpoint>,
) -> ApplyResult<SequentialCheckpoint>
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
impl ApplyConfig
Sourcepub fn new(game_path: impl Into<PathBuf>) -> Self
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.
Sourcepub fn max_cached_fds(&self) -> usize
pub fn max_cached_fds(&self) -> usize
Returns the configured cap on the open-file-handle cache.
Sourcepub fn buffer_capacity(&self) -> usize
pub fn buffer_capacity(&self) -> usize
Returns the configured per-handle write buffer capacity, in bytes.
Sourcepub fn ignore_missing(&self) -> bool
pub fn ignore_missing(&self) -> bool
Returns the configured ignore_missing flag.
Sourcepub fn ignore_old_mismatch(&self) -> bool
pub fn ignore_old_mismatch(&self) -> bool
Returns the configured ignore_old_mismatch flag.
Sourcepub fn with_platform(self, platform: Platform) -> Self
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.
Sourcepub fn with_ignore_missing(self, v: bool) -> Self
pub fn with_ignore_missing(self, v: bool) -> Self
Silently ignore missing files instead of returning an error during apply.
Sourcepub fn with_ignore_old_mismatch(self, v: bool) -> Self
pub fn with_ignore_old_mismatch(self, v: bool) -> Self
Silently ignore old-data mismatches instead of returning an error during apply.
Sourcepub fn with_vfs(self, vfs: impl Vfs + 'static) -> Self
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.
Sourcepub fn with_observer(self, observer: impl ApplyObserver + 'static) -> Self
pub fn with_observer(self, observer: impl ApplyObserver + 'static) -> Self
Install an ApplyObserver for progress reporting and cancellation.
Sourcepub fn with_cancel_token(self, token: CancelToken) -> Self
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.
Sourcepub fn with_checkpoint_sink(self, sink: impl CheckpointSink + 'static) -> Self
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.
Sourcepub fn with_max_cached_fds(self, n: usize) -> Self
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.
Sourcepub fn with_buffer_capacity(self, bytes: usize) -> Self
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.
Sourcepub fn into_session(self) -> ApplySession
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§
Auto Trait Implementations§
impl Freeze for ApplyConfig
impl !RefUnwindSafe for ApplyConfig
impl Send for ApplyConfig
impl Sync for ApplyConfig
impl Unpin for ApplyConfig
impl UnsafeUnpin for ApplyConfig
impl !UnwindSafe for ApplyConfig
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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