use crate::private::get_api;
use crate::sys;
use std::mem::transmute;
#[derive(Copy, Clone, Debug)]
pub struct Rid(pub(crate) sys::godot_rid);
impl Rid {
#[inline]
pub fn new() -> Self {
Rid::default()
}
#[inline]
pub unsafe fn get_id(self) -> i32 {
assert!(self.is_occupied());
(get_api().godot_rid_get_id)(&self.0)
}
#[inline]
pub fn is_occupied(self) -> bool {
self.to_u64() != 0
}
#[inline]
fn to_u64(self) -> u64 {
unsafe {
transmute::<_, usize>(self.0) as _
}
}
#[doc(hidden)]
#[inline]
#[allow(clippy::trivially_copy_pass_by_ref)]
pub fn sys(&self) -> *const sys::godot_rid {
&self.0
}
#[doc(hidden)]
#[inline]
pub fn sys_mut(&mut self) -> *mut sys::godot_rid {
&mut self.0
}
#[doc(hidden)]
#[inline]
pub fn from_sys(sys: sys::godot_rid) -> Self {
Rid(sys)
}
}
impl_basic_traits_as_sys! {
for Rid as godot_rid {
Default => godot_rid_new;
Eq => godot_rid_operator_equal;
Ord => godot_rid_operator_less;
}
}