How to parse array of bitfields?
xikxp1 opened this issue · 0 comments
xikxp1 commented
Hello!
What is the supposed way to parse array of bitfields?
For example let's try to parse CarIdxSessionFlags
value:
- Let's parse it as
&[Flags]
:
let car_idx_session_flags = s.find_var("CarIdxSessionFlags");
let car_idx_session_flags: &[Flags] = match s
.value(&car_idx_session_flags)
{
Ok(value) => value,
Err(err) => {
error!("Failed to get CarIdxSessionFlags value: {:?}", err);
}
};
This cannot be compiled because there is no TryFrom
implementation for &[Flags]
- Let's parse it as
&[i32]
:
let car_idx_session_flags = s.find_var("CarIdxSessionFlags");
let car_idx_session_flags: &[i32] = match s
.value(&car_idx_session_flags)
{
Ok(value) => value,
Err(err) => {
error!("Failed to get CarIdxSessionFlags value: {:?}", err);
}
};
let player_flags_value =
car_idx_session_flags[player_car_idx_value as usize];
let player_flags = Flags::from_bits_truncate(player_flags_value as u32);
This one fails at runtime because of InvalidType
error