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.§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
§impl PartialOrd for InstanceId
impl PartialOrd for InstanceId
§impl ToGodot for InstanceId
impl ToGodot for InstanceId
§type ToVia<'v> = i64
type ToVia<'v> = i64
to_godot()
, which differs from Via
for pass-by-reference types.§fn to_godot(&self) -> <InstanceId as ToGodot>::ToVia<'_>
fn to_godot(&self) -> <InstanceId as ToGodot>::ToVia<'_>
§fn to_variant(&self) -> Variant
fn to_variant(&self) -> 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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)