Struct asuran::repository::backend::common::generic_flatfile::GenericFlatFile [−][src]
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
pub fn new_raw(
file: F,
path: impl AsRef<Path>,
settings: Option<ChunkSettings>,
key: Key,
enc_key: Option<EncryptedKey>
) -> Result<GenericFlatFile<F>>
pub fn new_raw(
file: F,
path: impl AsRef<Path>,
settings: Option<ChunkSettings>,
key: Key,
enc_key: Option<EncryptedKey>
) -> Result<GenericFlatFile<F>>
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
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
type SyncManifest = Self
type SyncIndex = Self
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
type Iterator = IntoIter<StoredArchive>
Auto Trait Implementations
impl<F> RefUnwindSafe for GenericFlatFile<F> where
F: RefUnwindSafe,
impl<F> Send for GenericFlatFile<F> where
F: Send,
impl<F> Sync for GenericFlatFile<F> where
F: Sync,
impl<F> Unpin for GenericFlatFile<F> where
F: Unpin,
impl<F> UnwindSafe for GenericFlatFile<F> where
F: UnwindSafe,
Blanket Implementations
Mutably borrows from an owned value. Read more
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