Crate rscache[][src]

Expand description

An immutable, high-level API for the RuneScape cache file system.

This crate provides convenient access to the binary file system of the Oldschool RuneScape and RuneScape 3 caches.

The library’s API is mainly focused around reading bytes easily. Therefore, it offers a higher level of abstraction compared to other libraries. Most cache API’s expose a wide variety of internal types to let the user tinker around with the cache in unusual ways. To avoid undefined behavior, most internal types are kept private. The goal of this crate is to provide a simple interface for basic reading of valuable data.

Note that this crate is still evolving; both OSRS & RS3 are not fully supported/implemented and will probably contain bugs or miss vital features. If this is the case for you then consider opening an issue.

Safety

This crate internally uses memmap and this is safe because: the RuneScape cache is a read-only binary file system which is never modified by any process, and should never be modified. Mmap provides basic file safety with std::file::File. It is not possible to prevent parallel access to a certain file and prevent modifications. Therefore file-backed mapped memory is inherently unsafe.

Features

The cache’s protocol defaults to OSRS. In order to use the RS3 protocol you can enable the rs3 feature flag. A lot of types derive serde’s Serialize and Deserialize. To enable (de)serialization on most types use the serde-derive feature flag.

Quick Start

use rscache::Cache;

let cache = Cache::new("./data/osrs_cache")?;

let index_id = 2; // Config index.
let archive_id = 10; // Archive containing item definitions.

let buffer: Vec<u8> = cache.read(index_id, archive_id)?;

Loaders

In order to get definitions you can look at the loaders this library provides. The loaders use the cache as a dependency to parse in their data and cache the relevant definitions internally. The loader module also tells you how to make a loader if this crate doesn’t (yet) provide it.

Note: Some loaders cache these definitions lazily because of either the size of the data or the performance. The map loader for example is both slow and large so caching is by default lazy. Lazy loaders require mutability.

Modules

Validator for the cache.

(De)compression and enciphering/deciphering.

Defines RuneScape data structures.

Error management.

Extension traits.

Loaders for definitions.

Faster parsers using nom.

Helpful utility functions, macros and structs.

Structs

A parsed Jagex cache.

Enums

Super error type for all sub cache errors

Type Definitions

A specialized result type for cache operations.