Struct asuran_core::repository::chunk::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

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.

Constructs a Chunk from its raw parts.

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

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.

Returns the length of the data in the Chunk

Determine if this chunk is empty

Returns a reference to the raw bytes of this chunk

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

Returns the mac value of this chunk

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

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Deserialize this value from the given Serde deserializer. Read more

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more

Instruments this type with the current Span, returning an Instrumented wrapper. Read more

Performs the conversion.

Should always be Self

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

🔬 This is a nightly-only experimental API. (toowned_clone_into)

recently added

Uses borrowed data to replace owned data, usually by cloning. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

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