Resources

Struct Resources 

Source
pub struct Resources {
    pub list: Arc<Mutex<Vec<Arc<Resource>>>>,
    /* private fields */
}
Expand description

Data structure representing a resource file. This data structure points to a .res or .exe file and allows loading and modifying resource in this file.

Fields§

§list: Arc<Mutex<Vec<Arc<Resource>>>>

resources contained in the supplied file represented by the Resource data structure.

Implementations§

Source§

impl Resources

Source

pub fn new(file: &Path) -> Resources

Create new instance of the resource manager bound to a specific resource file. Once created, the resource file should be opened using Resources::open() or Resources::load().

Source

pub fn load(&self) -> Result<(), Error>

Load resources from the resource file. This function does not need to be called explicitly as Resources::open will call it. It is useful if you want to load resources for extraction purposes only.

Source

pub fn module_handle(&self) -> Arc<Mutex<Option<HANDLE>>>

Source

pub fn is_open(&self) -> bool

returns true if the resource file is currently open

Source

pub fn open(&mut self) -> Result<&Self, Error>

Open the resource file. This function opens a Windows handle to the resource file and must be followed by Resources::close.

Source

pub fn open_delete_existing_resources(&mut self) -> Result<&Self, Error>

Opens the resource file with delete_existing_resources set to true. This will result in retention in a deletion of previously existing resources.

Source

pub fn remove(&self, resource: &Resource) -> Result<&Self, Error>

Remove the supplied resource from the resource file.

Source

pub fn remove_with_args( &self, kind: &Id, name: &Id, lang: u16, ) -> Result<&Self, Error>

Remove the resource from the resource file by specifying resource type, name and lang. WARNING: If this method fails, the entire update set may fail (this is true for any API calls). As such it is highly recommended to use Resources::remove instead and supplying and existing Resource struct as it ensures that all supplied information is correct. This method is provided for advanced usage only.

Source

pub fn try_replace(&self, resource: &Resource) -> Result<&Self, Error>

Replace (Update) the resource in the resource file. It is expected that this is the original resource with the modified raw data.

Source

pub fn replace_with_args( &self, kind: &Id, name: &Id, lang: u16, data: &[u8], ) -> Result<&Self, Error>

Replace (Update) the resource in the resource file by supplying the resource type, name and lang as well as a u8 slice containing the raw resource data. Please note that if this function fails the entire resoruce update set may fail.

Source

pub fn close(&mut self)

Close the resource file. This applies all the changes (updates) to the resource file.

Source

pub fn discard(&mut self)

Close the resource file discarding all changes.

Source

pub fn insert(&self, r: Resource)

Create a new resource entry in the resource file. This function expects a valid Resource structure containing an appropriate resource type, name and raw data.

Source

pub fn find(&self, typeid: Id, nameid: Id) -> Option<Arc<Resource>>

Locate a resource entry by type and name.

Source

pub fn get_version_info(&self) -> Result<Option<VersionInfo>, Error>

Locate and deserialize VS_VERSIONINFO structure (represented by VersionInfo).

Trait Implementations§

Source§

impl Debug for Resources

Source§

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

Formats the value using the given formatter. Read more
Source§

impl Drop for Resources

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more

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

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.