Enum ResourceData

Source
pub enum ResourceData {
    File(PathBuf),
    Buffer(Vec<u8>),
    ArchiveOffset {
        offset: u32,
        size: u32,
    },
}
Expand description

ERF resource data source

Variants§

§

File(PathBuf)

The resource data is located in a separate file

§

Buffer(Vec<u8>)

The resource data is located here in a buffer

§

ArchiveOffset

The resource data is located in the ERF file and is not available because the ERF file has not been loaded in memory

Fields

§offset: u32
§size: u32

Implementations§

Source§

impl ResourceData

Source

pub fn len(&self) -> Option<usize>

Returns the length of the resource in bytes. None if it is unknown

Source

pub fn is_empty(&self) -> Option<bool>

Source

pub fn file_read(&self) -> Result<Vec<u8>, Error>

Read the file of a ResourceData::File and returns its data

§Panics

If self is not a ResourceData::File

Source

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

Converts a ResourceData::File into a ResourceData::Buffer by loading the file content in memory

§Panics

If self is not a ResourceData::File

Source

pub fn archiveoffset_seek( &self, stream: &mut (impl Seek + Read), ) -> Result<Vec<u8>, Error>

Seeks and returns the data pointed by the ResourceData::ArchiveOffset

This is typically used to fetch a resource data when only the head of the ERF file has been parsed

§Panics

If self is not a ResourceData::ArchiveOffset

Source

pub fn archiveoffset_load_stream( &mut self, stream: &mut (impl Seek + Read), ) -> Result<(), Error>

Converts a ResourceData::ArchiveOffset into a ResourceData::Buffer by loading the file content in memory

§Panics

If self is not a ResourceData::ArchiveOffset

Source

pub fn archiveoffset_load( &mut self, buffer: &[u8], buffer_offset: u32, ) -> Result<(), String>

Converts a ResourceData::ArchiveOffset into a ResourceData::Buffer by referencing data from buffer

§Args:
  • buffer: bytes buffer containing the archive data
  • buffer_offset: offset if the buffer has been truncated
§Panics

If self is not a ResourceData::ArchiveOffset

Trait Implementations§

Source§

impl Debug for ResourceData

Source§

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

Formats the value using the given formatter. 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.