Struct ObbyArchive

Source
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 both Read and Seek traits, such as std::fs::File or std::io::Cursor.

Implementations§

Source§

impl<R: Read + Seek> ObbyArchive<R>

Source

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 the Read and Seek traits (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();
Source

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.

Source

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.

Trait Implementations§

Source§

impl<R: Debug + Read + Seek> Debug for ObbyArchive<R>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<R> Freeze for ObbyArchive<R>
where R: Freeze,

§

impl<R> RefUnwindSafe for ObbyArchive<R>
where R: RefUnwindSafe,

§

impl<R> Send for ObbyArchive<R>
where R: Send,

§

impl<R> Sync for ObbyArchive<R>
where R: Sync,

§

impl<R> Unpin for ObbyArchive<R>
where R: Unpin,

§

impl<R> UnwindSafe for ObbyArchive<R>
where R: 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.