Pk2

Struct Pk2 

Source
pub struct Pk2<Buffer, L: LockChoice> { /* private fields */ }
Expand description

A Pk2 archive.

Implementations§

Source§

impl<L: LockChoice> Pk2<File, L>

Source

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

pub fn open<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<ReadOnly<File>, L>

Source

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>

Source

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>
where B: Read + Seek, L: LockChoice,

Source

pub fn chain_index(&self) -> &ChainIndex

Returns a reference to the chain index.

Source

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>
where B: Read + Write + Seek, L: LockChoice,

Source

pub fn create_new_in<K: AsRef<[u8]>>(stream: B, key: K) -> OpenResult<Self>

Source§

impl<B, L: LockChoice> Pk2<B, L>

Source

pub fn open_file<P: AsRef<str>>(&self, path: P) -> OpenResult<File<'_, B, L>>

Source

pub fn open_directory<P: AsRef<str>>( &self, path: P, ) -> OpenResult<Directory<'_, B, L>>

Source

pub fn open_root_dir(&self) -> Directory<'_, B, L>

Source

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>
where B: Read + Seek, L: LockChoice,

Source

pub fn read<P: AsRef<str>>(&self, path: P) -> OpenResult<Vec<u8>>

Source§

impl<B, L> Pk2<B, L>
where B: Read + Write + Seek, L: LockChoice,

Source

pub fn open_file_mut<P: AsRef<str>>( &mut self, path: P, ) -> OpenResult<FileMut<'_, B, L>>

Source

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

Source

pub fn create_file<P: AsRef<str>>( &mut self, path: P, ) -> OpenResult<FileMut<'_, B, L>>

Source

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.

Trait Implementations§

Source§

impl<L: LockChoice> From<Pk2<Cursor<Vec<u8>>, L>> for Vec<u8>

Source§

fn from(pk2: Pk2<Cursor<Vec<u8>>, L>) -> Self

Converts to this type from the input type.

Auto Trait Implementations§

§

impl<Buffer, L> Freeze for Pk2<Buffer, L>
where <L as LockChoice>::Lock<Buffer>: Freeze,

§

impl<Buffer, L> RefUnwindSafe for Pk2<Buffer, L>
where <L as LockChoice>::Lock<Buffer>: RefUnwindSafe, Buffer: RefUnwindSafe,

§

impl<Buffer, L> Send for Pk2<Buffer, L>
where <L as LockChoice>::Lock<Buffer>: Send, Buffer: Send,

§

impl<Buffer, L> Sync for Pk2<Buffer, L>
where <L as LockChoice>::Lock<Buffer>: Sync, Buffer: Sync,

§

impl<Buffer, L> Unpin for Pk2<Buffer, L>
where <L as LockChoice>::Lock<Buffer>: Unpin, Buffer: Unpin,

§

impl<Buffer, L> UnwindSafe for Pk2<Buffer, L>
where <L as LockChoice>::Lock<Buffer>: UnwindSafe, Buffer: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.