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§
Source§impl InstanceId
impl InstanceId
Sourcepub fn try_from_i64(id: i64) -> Option<Self>
pub fn try_from_i64(id: i64) -> Option<Self>
Constructs an instance ID from an integer, or None if the integer is zero.
This does not check if the instance is valid.
Sourcepub fn from_i64(id: i64) -> Self
pub fn from_i64(id: i64) -> Self
⚠️ 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
Sourcepub 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.
Sourcepub 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§
Source§impl Clone for InstanceId
impl Clone for InstanceId
Source§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 moreSource§impl Debug for InstanceId
impl Debug for InstanceId
Source§impl Display for InstanceId
impl Display for InstanceId
Source§impl FromGodot for InstanceId
impl FromGodot for InstanceId
Source§fn try_from_godot(via: Self::Via) -> Result<Self, ConvertError>
fn try_from_godot(via: Self::Via) -> Result<Self, ConvertError>
Err on failure.Source§fn from_godot(via: Self::Via) -> Self
fn from_godot(via: Self::Via) -> Self
Source§fn try_from_variant(variant: &Variant) -> Result<Self, ConvertError>
fn try_from_variant(variant: &Variant) -> Result<Self, ConvertError>
Variant], returning Err on failure.Source§fn from_variant(variant: &Variant) -> Self
fn from_variant(variant: &Variant) -> Self
Variant]. Read moreSource§impl GodotConvert for InstanceId
impl GodotConvert for InstanceId
Source§fn godot_shape() -> GodotShape
fn godot_shape() -> GodotShape
Source§impl Hash for InstanceId
impl Hash for InstanceId
Source§impl Ord for InstanceId
impl Ord for InstanceId
Source§fn cmp(&self, other: &InstanceId) -> Ordering
fn cmp(&self, other: &InstanceId) -> Ordering
1.21.0 · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Source§impl PartialEq for InstanceId
impl PartialEq for InstanceId
Source§impl PartialOrd for InstanceId
impl PartialOrd for InstanceId
Source§impl ToGodot for InstanceId
impl ToGodot for InstanceId
Source§type Pass = ByValue
type Pass = ByValue
Source§fn to_godot(&self) -> Self::Via
fn to_godot(&self) -> Self::Via
Source§fn to_godot_owned(&self) -> Self::Via
fn to_godot_owned(&self) -> Self::Via
Source§fn to_variant(&self) -> Variant
fn to_variant(&self) -> Variant
impl Copy for InstanceId
impl Eq for InstanceId
impl SimpleVar for InstanceId
impl StructuralPartialEq for InstanceId
Auto Trait Implementations§
impl Freeze for InstanceId
impl RefUnwindSafe for InstanceId
impl Send for InstanceId
impl Sync for InstanceId
impl Unpin for InstanceId
impl UnsafeUnpin for InstanceId
impl UnwindSafe for InstanceId
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Var for T
impl<T> Var for T
Source§fn var_get(field: &T) -> <T as GodotConvert>::Via
fn var_get(field: &T) -> <T as GodotConvert>::Via
Via type. Called for internal (non-pub) getters registered with Godot.Source§fn var_set(field: &mut T, value: <T as GodotConvert>::Via)
fn var_set(field: &mut T, value: <T as GodotConvert>::Via)
Via type. Called for internal (non-pub) setters registered with Godot.