Struct gdnative::core_types::Rid
source · pub struct Rid(_);
Expand description
A RID (“resource ID”) is an opaque handle that refers to a Godot Resource
.
RIDs do not grant access to the resource itself. Instead, they can be used in lower-level resource APIs
such as the servers. See also Godot API docs for RID
.
Note that RIDs are highly unsafe to work with (especially with a Release build of Godot):
- They are untyped, i.e. Godot does not recognize if they represent the correct resource type.
- The internal handle is interpreted as a raw pointer by Godot, meaning that passing an invalid or wrongly typed RID is instant undefined behavior.
For this reason, GDNative methods accepting Rid
parameters are marked unsafe
.
Implementations§
source§impl Rid
impl Rid
sourcepub unsafe fn get_id(self) -> i32
pub unsafe fn get_id(self) -> i32
Returns the ID of the referenced resource.
Panics
When this instance is empty, i.e. self.is_occupied()
is false.
Safety
RIDs are untyped and interpreted as raw pointers by the engine. If this method is called on an invalid resource ID, the behavior is undefined. This can happen when the resource behind the RID is no longer alive.
sourcepub fn is_occupied(self) -> bool
pub fn is_occupied(self) -> bool
Check if this RID is non-empty. This does not mean it’s valid or safe to use!
This simply checks if the handle has not been initialized with the empty default. It does not give any indication about whether it points to a valid resource.
Trait Implementations§
source§impl CoerceFromVariant for Rid
impl CoerceFromVariant for Rid
fn coerce_from_variant(v: &Variant) -> Rid
source§impl FromVariant for Rid
impl FromVariant for Rid
fn from_variant(variant: &Variant) -> Result<Rid, FromVariantError>
source§impl Ord for Rid
impl Ord for Rid
source§impl PartialOrd<Rid> for Rid
impl PartialOrd<Rid> for Rid
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
self
and other
) and is used by the <=
operator. Read moreimpl Copy for Rid
impl Eq for Rid
impl ToVariantEq for Rid
Auto Trait Implementations§
impl RefUnwindSafe for Rid
impl Send for Rid
impl Sync for Rid
impl Unpin for Rid
impl UnwindSafe for Rid
Blanket Implementations§
source§impl<Q, K> Equivalent<K> for Qwhere
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
impl<Q, K> Equivalent<K> for Qwhere
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.