[][src]Struct asuran::repository::Chunk

pub struct Chunk { /* fields omitted */ }

A binary blob, ready to be commited to storage

A Chunk is an arbitrary sequence of bytes, along with its associated ChunkID key.

Data in a Chunk has already undergone any selected compression and encryption, and has an associated HMAC tag used for verifying the integrity of the data. This HMAC tag is unrelated to the ChunkID key, and uses a separate HMAC key.

Chunks are additionally tagged with the encryption and compression modes used for them.

Methods

impl Chunk[src]

pub fn pack(
    data: Vec<u8>,
    compression: Compression,
    encryption: Encryption,
    hmac: HMAC,
    key: &Key
) -> Chunk
[src]

Produces a Chunk from the given data, using the specified encryption, and hmac algorithms, as well as the supplied key material.

Panics

Will panic if any of the compression, encryption, or HMAC operations fail. This would represent a massive programming oversight which the user of the library has little hope of recovering from safely without compromising cryptographic integrity.

pub fn from_parts(
    data: Vec<u8>,
    compression: Compression,
    encryption: Encryption,
    hmac: HMAC,
    mac: Vec<u8>,
    id: ChunkID
) -> Chunk
[src]

Constructs a Chunk from its raw parts.

This has potentially dangerous consequences if done incorrectly, and should be avoided if another method is available.

pub fn pack_with_id(
    data: Vec<u8>,
    compression: Compression,
    encryption: Encryption,
    hmac: HMAC,
    key: &Key,
    id: ChunkID
) -> Chunk
[src]

Produces a Chunk using the provided settings, but overriding the ChunkID key.

This has the potential to do serious damage to a repository if used incorrectly, and should be avoided if another method is available.

pub fn unpack(&self, key: &Key) -> Result<Vec<u8>, ChunkError>[src]

Validates, decrypts, and decompresses the data in a Chunk.

Errors

Will return Err(HMACVailidationFailed) if the chunk fails validation.

Will return Err(EncryptionError) if decryption fails.

Will return Err(CompressionError) if decompression fails.

All of these error values indicate that the Chunk is corrupted or otherwise malformed.

pub fn len(&self) -> usize[src]

Returns the length of the data in the Chunk

pub fn is_empty(&self) -> bool[src]

Determine if this chunk is empty

pub fn get_bytes(&self) -> &[u8][src]

Returns a reference to the raw bytes of this chunk

pub fn get_id(&self) -> ChunkID[src]

Returns the ChunkID key assocaited with the data in this chunk.

pub fn split(self) -> (ChunkHeader, ChunkBody)[src]

Splits a Chunk into its header and body components

pub fn unsplit(header: ChunkHeader, body: ChunkBody) -> Chunk[src]

Combines a header and a body into a Chunk

Trait Implementations

impl Clone for Chunk[src]

impl Debug for Chunk[src]

impl<'de> Deserialize<'de> for Chunk[src]

impl Eq for Chunk[src]

impl PartialEq<Chunk> for Chunk[src]

impl Serialize for Chunk[src]

Auto Trait Implementations

impl RefUnwindSafe for Chunk

impl Send for Chunk

impl Sync for Chunk

impl Unpin for Chunk

impl UnwindSafe for Chunk

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> DeserializeOwned for T where
    T: Deserialize<'de>, 
[src]

impl<Q, K> Equivalent<K> for Q where
    K: Borrow<Q> + ?Sized,
    Q: Eq + ?Sized
[src]

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

impl<T> Instrument for T[src]

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

impl<T> Same<T> for T

type Output = T

Should always be Self

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.

impl<V, T> VZip<V> for T where
    V: MultiLane<T>, 

impl<T> WithSubscriber for T[src]