[−][src]Struct rscache::Checksum
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
Auto Trait Implementations
impl RefUnwindSafe for Checksum
impl Send for Checksum
impl Sync for Checksum
impl Unpin for Checksum
impl UnwindSafe for Checksum
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,