Struct rscache::Cache

source ·
pub struct Cache { /* private fields */ }
Expand description

A complete virtual representation of the RuneScape cache file system.

Implementations§

source§

impl Cache

source

pub fn new<P: AsRef<Path>>(path: P) -> Result<Self, Error>

Creates a high level virtual memory map over the cache directory.

All files are isolated on allocation by keeping them as in-memory files.

Errors

The bulk of the errors which might occur are mostely I/O related due to acquiring file handles.

Other errors might include protocol changes in newer caches. Any error unrelated to I/O at this stage should be considered a bug.

source

pub fn checksum(&self) -> Result<Checksum, Error>

Generate a checksum based on the current cache.

The Checksum acts as a validator for individual cache files. Any RuneScape client will request a list of crc’s to check the validity of all of the file data that was transferred.

source

pub fn checksum_with<'a>( &self, keys: RsaKeys<'a> ) -> Result<RsaChecksum<'a>, Error>

Available on crate feature rs3 only.

Generate a checksum based on the current cache with RSA encryption.

RsaChecksum wraps a regular Checksum with the added benefit of encrypting the whirlpool hash into the checksum buffer.

source

pub fn read( &self, index_id: u8, archive_id: u32 ) -> Result<Buffer<Encoded>, Error>

Retrieves and constructs data corresponding to the given index and archive.

Errors

When trying to retrieve data from an index or an archive that does not exist the IndexNotFound or ArchiveNotFound errors are returned, respectively.

Any other errors such as sector validation failures or failed parsers should be considered a bug.

source

pub fn read_into_writer<W: Write>( &self, index_id: u8, archive_id: u32, writer: &mut W ) -> Result<(), Error>

Retrieves and writes data corresponding to the given index and archive into W.

Errors

See the error section on read for more details.

source

pub fn huffman_table(&self) -> Result<Buffer<Decoded>, Error>

Retrieves the huffman table.

Required when decompressing chat messages, see Huffman.

Trait Implementations§

source§

impl Debug for Cache

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl RefUnwindSafe for Cache

§

impl Send for Cache

§

impl Sync for Cache

§

impl Unpin for Cache

§

impl UnwindSafe for Cache

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> Same<T> for T

§

type Output = T

Should always be Self
source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.