pub struct Archive {
pub entries: Vec<Entry>,
/* private fields */
}Fields§
§entries: Vec<Entry>Implementations§
Source§impl Archive
impl Archive
Sourcepub fn new(file: File) -> Self
pub fn new(file: File) -> Self
Creates a new archive file. The file signature is written to the beginning of the file. The file is truncated to 0 bytes.
Sourcepub fn open(path: &str) -> Result<Self>
pub fn open(path: &str) -> Result<Self>
Opens an existing archive file for reading and writing. This will not overwrite the file, but append to it.
Sourcepub fn open_file(file: File) -> Result<Self>
pub fn open_file(file: File) -> Result<Self>
Opens an existing archive file for reading and writing. This will not overwrite the file, but append to it.
Sourcepub const fn version(&self) -> u8
pub const fn version(&self) -> u8
Retrieves the format version of the archive. This is the version of the archive format.
Sourcepub fn set_compression_callback(
&mut self,
callback: CompressionFormatCallback,
) -> &mut Self
pub fn set_compression_callback( &mut self, callback: CompressionFormatCallback, ) -> &mut Self
Sets the compression callback for the archive. This callback is called for each added file entry in the archive. The callback should return the compression format to use for the file.
Sourcepub fn set_real_size_callback(
&mut self,
callback: Option<Arc<dyn Fn(&Path) -> u64 + Send + Sync + 'static>>,
) -> &mut Self
pub fn set_real_size_callback( &mut self, callback: Option<Arc<dyn Fn(&Path) -> u64 + Send + Sync + 'static>>, ) -> &mut Self
Sets the “real” size callback for the archive. This callback is called for each added file entry in the archive. The callback should return the “real” size of the file.
Sourcepub fn add_directory(
&mut self,
path: &str,
progress: ProgressCallback,
) -> Result<&mut Self>
pub fn add_directory( &mut self, path: &str, progress: ProgressCallback, ) -> Result<&mut Self>
Adds all files in the given directory to the archive. (including subdirectories) This will append the directory to the end of the archive, if this directory already exists, it will not be replaced.
After this function is called, the existing header will be trimmed to the end of the archive, then readded upon completion.
§Panics
This function will panic if any filename is not valid UTF-8 or longer than 255 bytes.
Sourcepub fn into_entries(self) -> Vec<Entry>
pub fn into_entries(self) -> Vec<Entry>
Consumes the archive and returns the entries.
Sourcepub fn write_file_entry(
&mut self,
reader: impl Read,
size_real: Option<u64>,
name: impl Into<String>,
mode: EntryMode,
mtime: SystemTime,
owner: (u32, u32),
compression: CompressionFormat,
) -> Result<Box<FileEntry>>
pub fn write_file_entry( &mut self, reader: impl Read, size_real: Option<u64>, name: impl Into<String>, mode: EntryMode, mtime: SystemTime, owner: (u32, u32), compression: CompressionFormat, ) -> Result<Box<FileEntry>>
Writes a new file entry to the archive. This will NOT append the entry to the archive, it will write the content of the file to the archive and return the entry.
§Important
This function does not trim the end header or readd the end header, you will need to do that manually after calling this function.
Sourcepub fn add_entries(
&mut self,
entries: Vec<DirEntry>,
progress: ProgressCallback,
) -> Result<&mut Self>
pub fn add_entries( &mut self, entries: Vec<DirEntry>, progress: ProgressCallback, ) -> Result<&mut Self>
Adds a single file entry to the archive. (including subdirectories) This will append the entry to the end of the archive, if this entry already exists, it will not be replaced.
After this function is called, the existing header will be trimmed to the end of the archive, then readded upon completion.
§Panics
This function will panic if any filename is not valid UTF-8 or longer than 255 bytes.
Sourcepub fn find_archive_entry(&self, entry_name: &Path) -> Option<&Entry>
pub fn find_archive_entry(&self, entry_name: &Path) -> Option<&Entry>
Finds an entry in the archive by name.
Returns None if the entry is not found.
The entry name is the path inside the archive.
Example: “world/user/level.dat” would be a valid entry name.
Sourcepub fn find_archive_entry_mut(
&mut self,
entry_name: &Path,
) -> Option<&mut Entry>
pub fn find_archive_entry_mut( &mut self, entry_name: &Path, ) -> Option<&mut Entry>
Finds an entry in the archive by name.
Returns None if the entry is not found.
The entry name is the path inside the archive.
Example: “world/user/level.dat” would be a valid entry name.
pub fn trim_end_header(&mut self) -> Result<()>
pub fn write_end_header(&mut self) -> Result<()>
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Archive
impl !RefUnwindSafe for Archive
impl Send for Archive
impl Sync for Archive
impl Unpin for Archive
impl !UnwindSafe for Archive
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more