Struct godot::prelude::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.
Trait Implementations§
§impl Clone for InstanceId
impl Clone for InstanceId
§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 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>
Converts the Godot representation to this type, returning
Err
on failure.§fn from_godot(via: Self::Via) -> Self
fn from_godot(via: Self::Via) -> Self
⚠️ Converts the Godot representation to this type. Read more
§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.§fn from_variant(variant: &Variant) -> Self
fn from_variant(variant: &Variant) -> Self
§impl GodotConvert for InstanceId
impl GodotConvert for InstanceId
§impl Hash for InstanceId
impl Hash for InstanceId
§impl Ord for InstanceId
impl Ord for InstanceId
§impl PartialEq for InstanceId
impl PartialEq for InstanceId
§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 ==
.§impl PartialOrd for InstanceId
impl PartialOrd for InstanceId
§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 more§impl ToGodot for InstanceId
impl ToGodot for InstanceId
§fn to_godot(&self) -> <InstanceId as GodotConvert>::Via
fn to_godot(&self) -> <InstanceId as GodotConvert>::Via
Converts this type to the Godot type by reference, usually by cloning.
§fn into_godot(self) -> Self::Via
fn into_godot(self) -> Self::Via
Converts this type to the Godot type. Read more
§fn to_variant(&self) -> Variant
fn to_variant(&self) -> Variant
Converts this type to a Variant.
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
)