pub struct Pk2<Buffer, L: LockChoice> { /* private fields */ }Expand description
A Pk2 archive.
Implementations§
Source§impl<L: LockChoice> Pk2<File, L>
impl<L: LockChoice> Pk2<File, L>
Sourcepub fn create_new<P: AsRef<Path>, K: AsRef<[u8]>>(
path: P,
key: K,
) -> OpenResult<Self>
pub fn create_new<P: AsRef<Path>, K: AsRef<[u8]>>( path: P, key: K, ) -> OpenResult<Self>
Creates a new File based archive at the given path.
Source§impl<L: LockChoice> Pk2<ReadOnly<File>, L>
impl<L: LockChoice> Pk2<ReadOnly<File>, L>
Sourcepub fn open_readonly<P: AsRef<Path>, K: AsRef<[u8]>>(
path: P,
key: K,
) -> OpenResult<Self>
pub fn open_readonly<P: AsRef<Path>, K: AsRef<[u8]>>( path: P, key: K, ) -> OpenResult<Self>
Opens an archive at the given path.
Note this eagerly parses the whole archive’s file table into memory incurring a lot of read operations on the file making this operation potentially slow.
Source§impl<L: LockChoice> Pk2<Cursor<Vec<u8>>, L>
impl<L: LockChoice> Pk2<Cursor<Vec<u8>>, L>
Sourcepub fn create_new_in_memory<K: AsRef<[u8]>>(key: K) -> Result<Self, InvalidKey>
pub fn create_new_in_memory<K: AsRef<[u8]>>(key: K) -> Result<Self, InvalidKey>
Creates a new archive in memory.
Source§impl<B, L> Pk2<B, L>
impl<B, L> Pk2<B, L>
Sourcepub fn chain_index(&self) -> &ChainIndex
pub fn chain_index(&self) -> &ChainIndex
Returns a reference to the chain index.
Sourcepub fn open_in<K: AsRef<[u8]>>(stream: B, key: K) -> OpenResult<Self>
pub fn open_in<K: AsRef<[u8]>>(stream: B, key: K) -> OpenResult<Self>
Opens an archive from the given stream.
Note this eagerly parses the whole archive’s file table into memory incurring a lot of read operations on the stream.
Source§impl<B, L> Pk2<B, L>
impl<B, L> Pk2<B, L>
pub fn create_new_in<K: AsRef<[u8]>>(stream: B, key: K) -> OpenResult<Self>
Source§impl<B, L: LockChoice> Pk2<B, L>
impl<B, L: LockChoice> Pk2<B, L>
pub fn open_file<P: AsRef<str>>(&self, path: P) -> OpenResult<File<'_, B, L>>
pub fn open_directory<P: AsRef<str>>( &self, path: P, ) -> OpenResult<Directory<'_, B, L>>
pub fn open_root_dir(&self) -> Directory<'_, B, L>
Sourcepub fn for_each_file(
&self,
base: impl AsRef<str>,
cb: impl FnMut(&Path, File<'_, B, L>) -> OpenResult<()>,
) -> OpenResult<()>
pub fn for_each_file( &self, base: impl AsRef<str>, cb: impl FnMut(&Path, File<'_, B, L>) -> OpenResult<()>, ) -> OpenResult<()>
Invokes cb on every file in the sub directories of base, including
files inside of its subdirectories. Cb gets invoked with its
relative path to base and the file object.
Source§impl<B, L> Pk2<B, L>
impl<B, L> Pk2<B, L>
pub fn open_file_mut<P: AsRef<str>>( &mut self, path: P, ) -> OpenResult<FileMut<'_, B, L>>
Sourcepub fn delete_file<P: AsRef<str>>(&mut self, path: P) -> OpenResult<()>
pub fn delete_file<P: AsRef<str>>(&mut self, path: P) -> OpenResult<()>
Currently only replaces the entry with an empty one making the data inaccessible by normal means
pub fn create_file<P: AsRef<str>>( &mut self, path: P, ) -> OpenResult<FileMut<'_, B, L>>
Sourcepub fn create_file_truncate<P: AsRef<str>>(
&mut self,
path: P,
) -> OpenResult<FileMut<'_, B, L>>
pub fn create_file_truncate<P: AsRef<str>>( &mut self, path: P, ) -> OpenResult<FileMut<'_, B, L>>
Creates a file at the given path, or truncates it if it already exists.
If the file already exists, it will be opened for writing with its contents discarded. The existing file entry is retained. If the file does not exist, a new file is created.