Struct ovba::Project

source ·
pub struct Project {
    pub information: Information,
    pub references: Vec<Reference>,
    pub modules: Vec<Module>,
    /* private fields */
}
Expand description

Represents a VBA project.

This type serves as the entry point into this crate’s functionality and exposes the public API surface.

Fields§

§information: Information

Specifies version-independent information for the VBA project.

§references: Vec<Reference>

Specifies the external references of the VBA project.

§modules: Vec<Module>

Specifies the modules in the project.

Implementations§

source§

impl Project

source

pub fn decompress_stream_from<P>( &self, stream_path: P, offset: usize ) -> Result<Vec<u8>>
where P: AsRef<Path>,

Returns a stream’s decompressed data.

This function reads a stream referenced by stream_path and passes the data starting at offset into the RLE decompressor.

The primary use case for this function is to extract source code from VBA Modules. The respective offset is reported by Module::text_offset.

This is a low-level function that is useful for very specific use cases only. Client code that needs to read source code should use Project::module_source or Project::module_source_raw instead.

source

pub fn list(&self) -> Result<Vec<(String, String)>>

Returns a list of entries (storages and streams) in the raw binary data. Each entry is represented as a tuple of two Strings, where the first element contains the entry’s name and the second element the entry’s path inside the CFB.

The raw binary data is encoded as a Compound File Binary

source

pub fn module_source(&self, name: &str) -> Result<String>

Returns a module’s source code.

Similar to Project::module_source_raw this function returns the source code of a project’s module. After the raw source code has been decoded it is then converted to a String using the project’s code page.

source

pub fn module_source_raw(&self, name: &str) -> Result<Vec<u8>>

Returns the raw source code from a module.

The result contains a module’s source code as is. No character encoding conversion is done. The data is encoded using the project’s code page available through Information::code_page.

source

pub fn read_stream<P>(&self, stream_path: P) -> Result<Vec<u8>>
where P: AsRef<Path>,

Returns a stream’s contents.

This is a low-level function operating on the CFB data. The CFB is the storage container of the raw binary VBA project.

Auto Trait Implementations§

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>,

§

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>,

§

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.