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
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 |
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 |
Result | A specialized result type for cache operations. |
Rs3Cache | Type alias for |