Struct InstanceId
pub struct InstanceId { /* private fields */ }
Expand description
Represents a non-zero instance ID.
This is its own type for type safety and to deal with the inconsistent representation in Godot as both u64
(C++) and i64
(GDScript).
You can usually treat this as an opaque value and pass it to and from GDScript; there are conversion methods however.
Implementations§
§impl InstanceId
impl InstanceId
pub fn try_from_i64(id: i64) -> Option<InstanceId>
pub fn try_from_i64(id: i64) -> Option<InstanceId>
Constructs an instance ID from an integer, or None
if the integer is zero.
This does not check if the instance is valid.
pub fn from_i64(id: i64) -> InstanceId
pub fn from_i64(id: i64) -> InstanceId
⚠️ Constructs an instance ID from a non-zero integer, or panics.
This does not check if the instance is valid.
§Panics
If id
is zero. Use try_from_i64
if you are unsure.
pub fn to_i64(self) -> i64
pub fn is_ref_counted(self) -> bool
pub fn is_ref_counted(self) -> bool
Returns if the obj being referred-to is inheriting RefCounted
.
This is a very fast operation and involves no engine round-trip, as the information is encoded in the ID itself.
pub fn lookup_validity(self) -> bool
pub fn lookup_validity(self) -> bool
Dynamically checks if the instance behind the ID exists.
Rather slow, involves engine round-trip plus object DB lookup. If you need the object, use
Gd::from_instance_id()
instead.
This corresponds to Godot’s global function is_instance_id_valid()
.
Trait Implementations§
§impl Clone for InstanceId
impl Clone for InstanceId
§fn clone(&self) -> InstanceId
fn clone(&self) -> InstanceId
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more§impl Debug for InstanceId
impl Debug for InstanceId
§impl Display for InstanceId
impl Display for InstanceId
§impl FromGodot for InstanceId
impl FromGodot for InstanceId
§fn try_from_godot(
via: <InstanceId as GodotConvert>::Via,
) -> Result<InstanceId, ConvertError>
fn try_from_godot( via: <InstanceId as GodotConvert>::Via, ) -> Result<InstanceId, ConvertError>
Err
on failure.§fn from_godot(via: Self::Via) -> Self
fn from_godot(via: Self::Via) -> Self
§fn try_from_variant(variant: &Variant) -> Result<Self, ConvertError>
fn try_from_variant(variant: &Variant) -> Result<Self, ConvertError>
Variant
, returning Err
on failure.