1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
use std::io::{Read, Seek};
use binread::{BinRead, BinReaderExt, BinResult, ReadOptions};
#[cfg(feature = "derive_serde")]
use serde::{Deserialize, Serialize};
#[cfg_attr(feature = "derive_serde", derive(Serialize, Deserialize))]
#[derive(BinRead, Debug)]
pub struct MeshItem {
pub mesh_index: i32,
pub buffer_offset: u32,
}
#[cfg_attr(feature = "derive_serde", derive(Serialize, Deserialize))]
#[derive(BinRead, Debug)]
pub struct Adj {
pub count: u32,
#[br(count = count)]
pub items: Vec<MeshItem>,
#[br(parse_with = read_to_end)]
pub buffer: Vec<i16>,
}
fn read_to_end<R: Read + Seek>(reader: &mut R, _ro: &ReadOptions, _: ()) -> BinResult<Vec<i16>> {
let mut buf = Vec::new();
while let Ok(v) = reader.read_le::<i16>() {
buf.push(v);
}
Ok(buf)
}