Struct godot_core::obj::InstanceId
source · 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.
Trait Implementations§
source§impl Clone for InstanceId
impl Clone for InstanceId
source§fn clone(&self) -> InstanceId
fn clone(&self) -> InstanceId
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
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>
Converts the Godot representation to this type, returning
Err
on failure.source§fn from_godot(via: Self::Via) -> Self
fn from_godot(via: Self::Via) -> Self
⚠️ Converts the Godot representation to this type. Read more
source§fn try_from_variant(variant: &Variant) -> Result<Self, ConvertError>
fn try_from_variant(variant: &Variant) -> Result<Self, ConvertError>
Performs the conversion from a [
Variant
], returning Err
on failure.source§fn from_variant(variant: &Variant) -> Self
fn from_variant(variant: &Variant) -> Self
⚠️ Performs the conversion from a [
Variant
]. Read moresource§impl GodotConvert for InstanceId
impl GodotConvert for InstanceId
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,
Compares and returns the maximum of two values. Read more
source§impl PartialEq for InstanceId
impl PartialEq for InstanceId
source§fn eq(&self, other: &InstanceId) -> bool
fn eq(&self, other: &InstanceId) -> bool
This method tests for
self
and other
values to be equal, and is used
by ==
.source§impl PartialOrd for InstanceId
impl PartialOrd for InstanceId
source§fn partial_cmp(&self, other: &InstanceId) -> Option<Ordering>
fn partial_cmp(&self, other: &InstanceId) -> Option<Ordering>
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for
self
and other
) and is used by the <=
operator. Read moresource§impl ToGodot for InstanceId
impl ToGodot for InstanceId
impl Copy for InstanceId
impl Eq 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 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
Mutably borrows from an owned value. Read more
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§default unsafe fn clone_to_uninit(&self, dst: *mut T)
default unsafe fn clone_to_uninit(&self, dst: *mut T)
🔬This is a nightly-only experimental API. (
clone_to_uninit
)source§impl<T> CloneToUninit for Twhere
T: Copy,
impl<T> CloneToUninit for Twhere
T: Copy,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
🔬This is a nightly-only experimental API. (
clone_to_uninit
)