[−][src]Struct asuran_core::repository::chunk::Chunk
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.
Implementations
impl Chunk
[src]
pub fn pack(
data: Vec<u8>,
compression: Compression,
encryption: Encryption,
hmac: HMAC,
key: &Key
) -> Chunk
[src]
data: Vec<u8>,
compression: Compression,
encryption: Encryption,
hmac: HMAC,
key: &Key
) -> Chunk
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]
data: Vec<u8>,
compression: Compression,
encryption: Encryption,
hmac: HMAC,
mac: Vec<u8>,
id: ChunkID
) -> Chunk
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]
data: Vec<u8>,
compression: Compression,
encryption: Encryption,
hmac: HMAC,
key: &Key,
id: ChunkID
) -> Chunk
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 mac(&self) -> Vec<u8>
[src]
Returns the mac
value of 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
pub fn encryption(&self) -> Encryption
[src]
Returns a copy of the encryption method/iv used for the chunk
Trait Implementations
impl Clone for Chunk
[src]
impl Debug for Chunk
[src]
impl<'de> Deserialize<'de> for Chunk
[src]
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>,
[src]
__D: Deserializer<'de>,
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]
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> DeserializeOwned for T where
T: for<'de> Deserialize<'de>,
[src]
T: for<'de> Deserialize<'de>,
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> Same<T> for T
type Output = T
Should always be Self
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>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,