use crate::ffi::{copy_cstr, vcall};
use std::ffi::{CStr, CString, c_int};
interface! {
#[doc(alias = "IVModelInfo")]
pub struct ModelInfo(sys::IVModelInfo) = Engine c"VModelInfoServer004";
}
impl<'s> ModelInfo<'s> {
#[doc(alias = "GetModelIndex")]
pub fn model_index(self, name: &CStr) -> Option<c_int> {
let index = unsafe { vcall!(self.as_ptr() => IVModelInfo_GetModelIndex(name.as_ptr())) };
(index >= 0).then_some(index)
}
#[doc(alias = "GetModelName")]
pub fn model_name(self, index: c_int) -> Option<CString> {
let model = unsafe { vcall!(self.as_ptr() => IVModelInfo_GetModel(index)) };
if model.is_null() {
return None;
}
unsafe { copy_cstr(vcall!(self.as_ptr() => IVModelInfo_GetModelName(model))) }
}
}