use crate::obj::{GodotClass, InstanceId};
#[derive(Clone, Debug)]
pub struct ObjectRtti {
instance_id: InstanceId,
#[cfg(safeguards_strict)] #[cfg_attr(published_docs, doc(cfg(safeguards_strict)))]
class_name: crate::meta::ClassId,
}
impl ObjectRtti {
#[inline]
pub fn of<T: GodotClass>(instance_id: InstanceId) -> Self {
Self {
instance_id,
#[cfg(safeguards_strict)] #[cfg_attr(published_docs, doc(cfg(safeguards_strict)))]
class_name: T::class_id(),
}
}
#[cfg(safeguards_strict)] #[cfg_attr(published_docs, doc(cfg(safeguards_strict)))]
#[inline]
pub fn check_type<T: GodotClass>(&self) {
crate::classes::ensure_object_inherits(self.class_name, T::class_id(), self.instance_id);
}
#[inline]
pub fn instance_id(&self) -> InstanceId {
self.instance_id
}
}