infinite_rs/tag/
data_reference.rs

1//! Reference to binary blob inside tag that isn't defined by a structure.
2
3use byteorder::{LE, ReadBytesExt};
4use std::io::BufRead;
5
6use crate::Result;
7use crate::common::extensions::Enumerable;
8
9#[derive(Default, Debug)]
10/// Structure that defines a reference to a blob of data inside tag data.
11pub struct TagDataReference {
12    /// The index of the tag struct containing the tag field.
13    pub parent_struct_index: i32,
14    /// Unknown: seems to vary (maybe enum?).
15    unknown: i32,
16    /// The index of the tag struct containing the referenced data.
17    /// Can be -1 for null references.
18    pub target_index: i32,
19    /// The index of the data block containing the tag field.
20    pub field_block: i32,
21    /// The offset of the tag field inside the data block.
22    pub field_offset: u32,
23}
24
25impl Enumerable for TagDataReference {
26    fn read<R: BufRead>(&mut self, reader: &mut R) -> Result<()> {
27        self.parent_struct_index = reader.read_i32::<LE>()?;
28        self.unknown = reader.read_i32::<LE>()?;
29        self.target_index = reader.read_i32::<LE>()?;
30        self.field_block = reader.read_i32::<LE>()?;
31        self.field_offset = reader.read_u32::<LE>()?;
32        Ok(())
33    }
34}