ireko/src/set_property.rs

49 lines
1.2 KiB
Rust
Raw Normal View History

2025-02-19 19:34:13 -05:00
use crate::StringBasedProperty;
use binrw::binrw;
#[binrw]
#[derive(Debug)]
pub struct SetEntry {
#[br(temp)]
#[bw(ignore)]
pub unk_name_length: u32,
#[br(count = unk_name_length)]
#[bw(map = |x : &String | x.as_bytes())]
#[br(map = | x: Vec<u8> | String::from_utf8(x).unwrap().trim_matches(char::from(0)).to_string())]
pub unk_name: String,
#[br(temp)]
#[bw(ignore)]
pub unk_type_length: u32,
#[br(count = unk_type_length)]
#[bw(map = |x : &String | x.as_bytes())]
#[br(map = | x: Vec<u8> | String::from_utf8(x).unwrap().trim_matches(char::from(0)).to_string())]
pub unk_type: String,
#[br(args { magic: &unk_type })]
2025-02-23 15:04:04 -05:00
2025-02-19 19:34:13 -05:00
pub key: StringBasedProperty,
}
#[binrw]
#[derive(Debug)]
pub struct SetProperty {
pub unk: u32,
#[br(temp)]
#[bw(ignore)]
#[br(pad_before = 4)]
pub key_name_length: u32,
#[br(count = key_name_length)]
#[bw(map = |x : &String | x.as_bytes())]
#[br(map = | x: Vec<u8> | String::from_utf8(x).unwrap().trim_matches(char::from(0)).to_string())]
pub key_name: String,
#[br(pad_before = 5)]
pub num_set_entries: u32,
#[br(count = num_set_entries)]
2025-02-19 19:34:13 -05:00
pub entries: Vec<SetEntry>,
}
// TODO: write test