Crate rscache[][src]

Expand description

Oldschool RuneScape & RuneScape 3 cache api for basic and simple cache interactions.

Features

Currently rs-cache offers limited support for OSRS & RS3 with the features listed below. This crate also contains tools to help you with implementing your own cache if the currently supplied cache is insufficient for a specific use-case.

Note: this crate is still a work in progress and might contain bugs and is still incomplete.

The following features are currently provided:

  • Reading from the cache.
  • Huffman buffer access.
  • Checksum with simple-to-use validation.
  • Compression and decompression:
  • OSRS Loaders
  • RS3 Loaders
  • Utilities
    • Huffman decompressor.
    • Isaac randomizer.
    • Xtea decipher.

Features to be implemented in the future:

  • Writing data to the cache.
  • LZMA compression.

Quick Start

The quickest and easiest way to get started is by using OsrsCache or Rs3Cache. (they work the same but use different reading methods)

use rscache::OsrsCache;
 
let cache = OsrsCache::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)?;
 

Cache interchangeability

The internal storage and reading functionalities can be changed by using the generic Cache struct and chosing a store implementation that fits a specific use-case.

In the below example the FileStore holds a handle to the main data file while the MemoryStore parses the entire main data file into memory. If the main file is too large for the MemoryStore you can opt into a FileStore to do reading through disk I/O.

The type OsrsCache is a type alias for Cache<MemoryStore>.

use rscache::{ Cache, store::FileStore };
 
let cache = Cache::<FileStore>::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)?;
 

Building a custom cache

This crate supplies traits and helper functions to help implement your own cache when the default cache doesn’t do exactly what you need.

See the custom_cache example to help you get started.

Modules

Archives with parsing and decoding.

Main cache implementation and traits.

Validator for the cache.

Compression and decompression of cache buffers.

Definitions for certain games.

Error management.

Extension traits.

Index with parsing.

Loading definitions for certain games.

Represents linked sectors in the main data file.

Store trait for cache interchangeability.

Helpful utility functions, macros and structs.

Structs

Main cache struct providing basic utilities.

Validator for the Cache.

Cache inner reading using a file handle.

Cache inner reading from memory.

Traits

The core of a cache.

The read functionality of a cache.

Marker trait for definitions.

The core of each Loader tasked with loading certain definitions.

The internal storage for a cache with a way to read internal data.

Type Definitions

Type alias for Cache<MemoryStore>.

A specialized result type for cache operations.

Type alias for Cache<FileStore>.