Struct gingerlib::Quest3DFile

source ·
pub struct Quest3DFile {
    pub tags: Vec<Tag>,
}
Expand description

Struct representing a channel group file, which is used by the Quest3D engine to store any kind of data. It contains several “tags”, which consist of a 4 character name and the data. The actual file will contain a 4-byte-long number indicating after the name, but this is not stored in the struct. Tags may also contain no data at all, which is the case for the A3DG tag, since it’s used as the magic number.

Fields§

§tags: Vec<Tag>

Implementations§

source§

impl Quest3DFile

source

pub fn read(path: &str) -> Result<Self, Box<dyn Error>>

Reads a file from the specified path.

This works with compressed and protected files too, in those cases it will automatically decompress it and remove the protection.

Example
use gingerlib::Quest3DFile;

let file = Quest3DFile::read("./test.cgr").unwrap();
assert_eq!(file.tags.len(), 150);
Returns

The loaded Quest3DFile.

Errors

Returns an std::io::Error if the file could not be opened.

source

pub fn to_bytes(&self) -> Vec<u8>

Converts the tags of the file to a byte vector.

Returns

A byte vector containing the tags.

source

pub fn save_to_file(&self, path: &str) -> Result<File, Error>

Saves the file to the specified path.

Returns

The File.

Errors

Returns an std::io::Error if the file could not be created.

Trait Implementations§

source§

impl Debug for Quest3DFile

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

§

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.