[][src]Struct rscache::Checksum

pub struct Checksum { /* fields omitted */ }

Validator for the Cache.

The Checksum is used to validate if every file used by the cache is still valid. It contains a list of entries, one entry for each index file. Every entry contains a crc and a revision.

In order to create the Checksum the create_checksum() function has to be called on Cache.

Implementations

impl Checksum[src]

pub fn validate(&self, crcs: &[u32]) -> bool[src]

Validates the given crcs with internal crcs of the Checksum.

Examples

// client crcs:
let crcs = vec![1593884597, 1029608590, 16840364, 4209099954, 3716821437, 165713182, 
                686540367, 4262755489, 2208636505, 3047082366, 586413816, 2890424900, 
                3411535427, 3178880569, 153718440, 3849392898, 0, 2813112885, 1461700456, 
                2751169400, 2927815226];
 
let valid = checksum.validate(&crcs);
 
assert!(valid);

pub fn encode(self) -> Result<Vec<u8>>[src]

Consumes the Checksum and encodes it into a byte buffer.

After encoding the checksum it can be sent to the client.

Errors

Returns a CacheError if the encoding fails.

Examples

fn encode_checksum(checksum: Checksum, stream: &mut TcpStream) -> rscache::Result<()> {
    let buffer = checksum.encode()?;
 
    stream.write_all(&buffer)?;
    Ok(())
}

Trait Implementations

impl Clone for Checksum[src]

impl Debug for Checksum[src]

impl Default for Checksum[src]

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.