pub struct ObbyArchive<R: Read + Seek> { /* private fields */ }Expand description
Main reader struct for working with .obby files from any source
The ObbyArchive struct is used to represent an archive file in the .obby format,
which is used by Obsidian plugins. It allows for listing and extracting the files
within the archive, and it handles both reading the metadata and the compressed file data.
§Type Parameters
R: A type that implements bothReadandSeektraits, such asstd::fs::Fileorstd::io::Cursor.
Implementations§
Source§impl<R: Read + Seek> ObbyArchive<R>
impl<R: Read + Seek> ObbyArchive<R>
Sourcepub fn new(reader: R) -> Result<Self>
pub fn new(reader: R) -> Result<Self>
Creates a new ObbyArchive from any source that implements Read and Seek
This function reads the .obby file format and extracts its metadata and entry
information. It verifies the file header and sets up the internal structure to allow
for extracting files from the archive.
§Arguments
reader- Any type that implements theReadandSeektraits (e.g.,File,Cursor).
§Returns
A Result containing either the created ObbyArchive instance or an io::Error if there was an issue reading the archive.
§Example
use obsidian_lib::ObbyArchive;
use std::fs::File;
let file = File::open("plugin.obby").unwrap();
let archive = ObbyArchive::new(file).unwrap();Sourcepub fn list_entries(&self) -> Vec<String>
pub fn list_entries(&self) -> Vec<String>
Returns a list of all entries in the archive
This function returns a vector of the entry names in the .obby archive.
§Returns
A Vec<String> containing the names of all entries.
Sourcepub fn extract_entry(&mut self, entry_name: &str) -> Result<Vec<u8>>
pub fn extract_entry(&mut self, entry_name: &str) -> Result<Vec<u8>>
Extracts a specific entry by name
This function extracts a specific entry from the .obby archive based on its name.
The entry data is returned as a vector of bytes.
§Arguments
entry_name- The name of the entry to extract.
§Returns
A Result containing a Vec<u8> of the extracted entry’s data if successful, or an io::Error if there was an issue extracting it.