[][src]Crate rscache

RuneScape cache api for basic and simple cache interactions.

Features

Currently rs-cache only supports OSRS 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.

The following features are currently provided:

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

Features to be implemented in the future:

  • Writing data to the cache.
  • RS3 protocol support. (including LZMA compression)

Quick Start

The quickest and easiest way to get started is by using OsrsCache.

use rscache::OsrsCache;
 
let cache = OsrsCache::new("./data/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/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

arc

Archives with parsing and decoding.

cache

Main cache implementation and traits.

cksm

Validator for the cache.

codec

Compression and decompression of cache buffers.

def

Definitions for certain games.

error

Error management.

ext

Extension traits.

idx

Index with parsing.

ldr

Loading definitions for certain games.

sec

Represents linked sectors in main data file.

store

Store trait for cache interchangeability.

util

Helpful utility functions, macros and structs.

Structs

Cache

Main cache struct providing basic utilities.

Checksum

Validator for the Cache.

FileStore

Cache inner reading using a file handle.

MemoryStore

Cache inner reading from memory.

Traits

CacheCore

The core of a cache.

CacheRead

The read functionality of a cache.

Definition

Marker trait for definitions.

Loader

The core of each Loader tasked with loading certain definitions.

Store

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

Type Definitions

OsrsCache

Type alias for Cache<MemoryStore>.

Result

A specialized result type for cache operations.