Struct asuran::repository::Chunk [−][src]
pub struct Chunk { /* fields omitted */ }
Expand description
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
pub fn pack(
data: Vec<u8, Global>,
compression: Compression,
encryption: Encryption,
hmac: HMAC,
key: &Key
) -> Chunk
pub fn pack(
data: Vec<u8, Global>,
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, Global>,
compression: Compression,
encryption: Encryption,
hmac: HMAC,
mac: Vec<u8, Global>,
id: ChunkID
) -> Chunk
pub fn from_parts(
data: Vec<u8, Global>,
compression: Compression,
encryption: Encryption,
hmac: HMAC,
mac: Vec<u8, Global>,
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, Global>,
compression: Compression,
encryption: Encryption,
hmac: HMAC,
key: &Key,
id: ChunkID
) -> Chunk
pub fn pack_with_id(
data: Vec<u8, Global>,
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.
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.
Splits a Chunk
into its header and body components
Combines a header and a body into a Chunk
Returns a copy of the encryption method/iv used for the chunk
Trait Implementations
pub fn deserialize<__D>(
__deserializer: __D
) -> Result<Chunk, <__D as Deserializer<'de>>::Error> where
__D: Deserializer<'de>,
pub fn deserialize<__D>(
__deserializer: __D
) -> Result<Chunk, <__D as Deserializer<'de>>::Error> where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
pub fn serialize<__S>(
&self,
__serializer: __S
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error> where
__S: Serializer,
pub fn serialize<__S>(
&self,
__serializer: __S
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error> where
__S: Serializer,
Serialize this value into the given Serde serializer. Read more
Auto Trait Implementations
impl RefUnwindSafe for Chunk
impl UnwindSafe for Chunk
Blanket Implementations
Mutably borrows from an owned value. Read more
Compare self to key
and return true
if they are equal.
Attaches the provided Subscriber
to this type, returning a
WithDispatch
wrapper. Read more
Attaches the current default Subscriber
to this type, returning a
WithDispatch
wrapper. Read more