[][src]Crate rscache

Utilities for RuneScape cache interaction.

Features

The following features are currently provided:

  • Reading from the cache.
  • Huffman buffer access.
  • Checksum with simple-to-use validation.
  • Compression and decompression:

Quick Start

A possible use case of this utility is to read data from the RuneScape cache and send them to the client during the update protocol. The example listed below quickly shows how you can pass the index_id and the archive_id to the cache and get the correct data to send to the client.

use rscache::{ Cache, CacheError, LinkedListExt };
 
fn process_update(packet: UpdatePacket, stream: &mut TcpStream) -> Result<(), CacheError> {
    // read the specified archive from the given index to an owned vector.
    let buffer = cache.read(packet.index_id, packet.archive_id)?.to_vec();
     
    // ... format buffer.
 
    // send formatted_buffer to client.
    stream.write_all(&formatted_buffer)?;
 
    Ok(())
}

In the above example the data that was read from the cache is transformed into a vector of bytes. You can also use the LinkedList<&[u8]> to iter() over the data_blocks instead of making the bytes owned.

let buffer = cache.read(packet.index_id, packet.archive_id)?;
 
for data_block in buffer.iter() {
    // data_block contains 512 byte slices that directly link into the MainData buffer.
    // this can be useful when creating a new formatted buffer.
}

Modules

codec

Provides two functions to encode/decode buffers.

Structs

Cache

Main struct which provides basic cache utilities and interactions.

Checksum

Used to check the validity of the cache.

Enums

CacheError
CompressionError
ReadError

Traits

LinkedListExt

Adds extensions onto the std collection: LinkedList<T>.