Skip to main content

Storage

Struct Storage 

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

Unified read-only CASC storage (local disk or CDN)

Storage is the primary entry point for reading CASC archives. Use open() for local disk, openOnline() for CDN-backed access. The same public read API works identically regardless of backing store.

All public methods are thread-safe: read operations acquire a shared lock.

Uses the PImpl (Pointer to Implementation) idiom to hide internals.

@see StorageWritable for write + persist operations.

Implementations§

Source§

impl Storage

Source

pub fn open(path: &str, pool: Option<&HostWorkerPool>) -> Option<Storage>

Open an existing local CASC storage. @param path Path to the game’s top-level directory (containing .build.info) or its Data subdirectory. @param pool Optional WorkerPool for parallel I/O (non-owning). @return A valid Storage, or std::nullopt on failure.

Source

pub fn open_path_locale_mask_pool( path: &str, locale_mask: u32, pool: Option<&HostWorkerPool>, ) -> Option<Storage>

@overload Open with locale mask.

Source

pub fn open_path_product_pool( path: &str, product: &str, pool: Option<&HostWorkerPool>, ) -> Option<Storage>

@overload Open a specific product from a multi-product .build.info. @param product Product code selecting the build, e.g. “w3” (Warcraft III retail) vs “w3t” (its PTR). Matched case-insensitively against the active builds; empty selects the first active build. See OpenOptions::product. Open fails if the product has no active build.

Source

pub fn close(&mut self)

Release all resources and invalidate the storage.

Source

pub fn is_local(&self) -> bool

@return True if this storage reads from local disk.

Source

pub fn is_online(&self) -> bool

@return True if this storage reads from CDN.

Source

pub fn is_writable(&self) -> bool

@return True if this storage has a write overlay (StorageWritable).

Source

pub fn root_format(&self) -> RootFormat

@return The root manifest format, or RootFormat::Unknown.

Source

pub fn read_file(&self, casc_path: &str) -> Option<Bytes>

@return File contents, or std::nullopt if the path is not found.

Source

pub fn read_file_casc_path_locale_flags_open_flags( &self, casc_path: &str, locale_flags: u32, open_flags: u32, ) -> Option<Bytes>

@overload Read a file by path with locale and open flags.

Source

pub fn read_file_file_id_hint( &self, file_id: i32, hint: FileIdHint, ) -> Option<Bytes>

@overload Read a file by WoW-style FileDataId.

Source

pub fn read_file_file_id_locale_flags_open_flags_hint( &self, file_id: i32, locale_flags: u32, open_flags: u32, hint: FileIdHint, ) -> Option<Bytes>

@overload Read a file by FileDataId with locale and open flags.

Source

pub fn file_exists(&self, casc_path: &str) -> bool

@return True if the path resolves to a known file.

Source

pub fn file_exists_file_id_hint(&self, file_id: i32, hint: FileIdHint) -> bool

@overload Check existence by FileDataId.

Source

pub fn file_size(&self, casc_path: &str) -> Option<u64>

@return Uncompressed file size, or std::nullopt if not found.

Source

pub fn file_size_file_id_hint( &self, file_id: i32, hint: FileIdHint, ) -> Option<u64>

@overload

Source

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

@return All known file paths.

Source

pub fn list_entries(&self) -> Vec<FindEntry>

@return All entries with metadata.

Source

pub fn total_file_count(&self) -> Option<u32>

@return Total number of files in the root manifest.

Source

pub fn import_keys_from_string(&mut self, key_list: &str) -> bool

Import encryption keys from a formatted string (one per line).

Source

pub fn import_keys_from_file(&mut self, key_file_path: &str) -> bool

Import encryption keys from a file.

Source

pub fn find_encryption_key(&self, key_name: u64) -> Option<[u8; 16]>

@return The encryption key for @p keyName, or std::nullopt if not found.

Source

pub fn flush_cache(&mut self)

Clear the in-memory decoded-data cache (container cache).

Source

pub fn prefetch(&mut self) -> bool

Force every deferred load (encoding, root, VFS, index files, orphan bitvector) to resolve. Idempotent.

Source

pub fn last_error() -> u32

@return Last error code (thread-local).

Source§

impl Storage

Source

pub fn open_online( product: &str, region: &str, http: &dyn AsHttpHandler, build_key: Option<&str>, cache_dir: Option<&str>, locale_mask: u32, pool: Option<&HostWorkerPool>, ) -> Option<Storage>

Open a CDN-backed (online) storage.

The returned Storage exposes the same read API as a local one.

  • product — product code, e.g. "wow", "w3", "d3", "fenris".
  • region — region for version lookup; empty defaults to "us".
  • http — HTTP transport; required.
  • build_key — optional hex build-config key; None takes the latest active build.
  • cache_dir — optional on-disk cache; None keeps everything in memory.
  • locale_mask — locale filter, 0 accepts all.
Source

pub fn read_batch(&self, requests: &[BatchReadRequest]) -> Vec<BatchReadResult>

Read every requested file in one native call.

Results come back in request order; an individual failure yields a result with data == None and does not affect the others. When the storage was opened with a worker pool, resolution / raw read / BLTE decode overlap across files — considerably faster than reading one file at a time.

Trait Implementations§

Source§

impl Debug for Storage

Source§

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

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

impl Drop for Storage

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

fn pin_drop(self: Pin<&mut Self>)

🔬This is a nightly-only experimental API. (pin_ergonomics)
Execute the destructor for this type, but different to Drop::drop, it requires self to be pinned. Read more
Source§

impl Send for Storage

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