use crate::util::{read_i32_le, read_u32_le};
#[derive(Clone, Copy, Debug)]
pub struct ParameterInfo<'a> {
bytes: &'a [u8],
}
impl<'a> ParameterInfo<'a> {
pub(crate) fn new(bytes: &'a [u8]) -> Self {
Self { bytes }
}
pub const SIZE: usize = 12;
#[inline]
pub fn datatype(&self) -> i32 {
read_i32_le(self.bytes, 0x00).unwrap_or(-1)
}
#[inline]
pub fn name_offset(&self) -> i32 {
read_i32_le(self.bytes, 0x04).unwrap_or(-1)
}
#[inline]
pub fn flags(&self) -> u32 {
read_u32_le(self.bytes, 0x08).unwrap_or(0)
}
#[inline]
pub fn is_in(&self) -> bool {
self.flags() & 0x01 != 0
}
#[inline]
pub fn is_out(&self) -> bool {
self.flags() & 0x02 != 0
}
#[inline]
pub fn is_retval(&self) -> bool {
self.flags() & 0x08 != 0
}
#[inline]
pub fn is_optional(&self) -> bool {
self.flags() & 0x10 != 0
}
}