Struct asuran::repository::backend::common::generic_flatfile::GenericFlatFile[][src]

pub struct GenericFlatFile<F: Read + Write + Seek + 'static> { /* fields omitted */ }
Expand description

A view over a generic FlatFile backend.

This generic backend can accept any (owned) Read + Write + Seek, and will implement the same binary format on top of it.

See module level documentation for details.

Implementations

Opens up a new GenericFlatFile over the provided Read + Write + Seek

If the given ‘file’ is empty, it will write the initial headers, otherwise, it will walk through all the headers and footers in the repository, and parse them in to their needed forms.

If the given ‘file’ is empty, and thus the repository is being initialized, chunk settings and an encrypted key must be passed.

Errors

  • If an underlying I/O Error occurs
  • If the caller is initializing a repository, but did not provide chunk settings or an encrypted key, Err(ManifestError)
  • If the caller provides an encrypted key for an already initialized repository
  • If decoding of the encrypted key or any of the headers/footers fails Err(FlatFileError)
  • If any of the chunks described by the footers do not have an associated ChunkHeader
  • If an already initalized repository does not contain any footers

Attempts to read an EncryptedKey from the header of the provided repository file

Errors

  • If an underlying I/O error occurs
  • If decoding the EncryptedKey fails

Trait Implementations

Formats the value using the given formatter. Read more

Executes the destructor for this type. Read more

This operation is not currently supported for FlatFile repositories, so we just return an error

Return the cached EncryptedKey

Glue together information from the cached index, the length_map, and the chunk_headers map to find the chunk in the file and reconstruct it.

Errors

  • If there is an underlying I/O error
  • If the location is not present in the length map (the chunk has not been seen before, or it has not been written with write_chunk
  • If the header is not present in the chunk_headers map

Simply looks up the chunk in the cached index map

Updates the cached index map, as well as adds the chunk to the EntryFooterData

Errors

Will return Err if the Chunk had not been previously written with write_chunk, and thus has an unknown length.

Collects the keys from the cached index map into a HashSet

Flush the EntryFooterDisk to disk and make a new one

Returns the size of the cached index map

Assumes archives were written in chronological order, and returns the timestamp of the last archive written.

Errors

Will return Err if there are no archives in this repository

Returns the cached ChunkSettings stored in the struct

Modifies the cached ChunkSettings, as well as the ones in the EntryFooterData. Additionally sets the dirty flag on the chunk settings, so if only the chunk settings were modified, this change will still get persisted to the repository.

Clones the cached manifest Vec and turns it into an iterator

Adds the archive to the cached manifest Vec, as well as to the EntryFooterData

This repository type does not support touching, so this does nothing

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 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