pub enum Rid {
Valid(NonZero<u64>),
Invalid,
}
Expand description
A RID (“resource ID”) is an opaque handle that refers to a Godot Resource
.
RIDs do not grant access to the resource itself. Instead, they can be used in lower-level resource APIs
such as the servers. See also Godot API docs for RID
.
RIDs should be largely safe to work with. Certain calls to servers may fail, however doing so will trigger an error from Godot, and will not cause any UB.
§Safety caveat
In Godot 3, RID
was not as safe as described here. We believe that this is fixed in Godot 4, but this has
not been extensively tested as of yet. Some confirmed UB from Godot 3 does not occur anymore, but if you
find anything suspicious or outright UB please open an issue.
Variants§
Valid(NonZero<u64>)
A valid RID may refer to some resource, but is not guaranteed to do so.
Invalid
An invalid RID will never refer to a resource. Internally it is represented as a 0.
Implementations§
§impl Rid
impl Rid
pub const fn to_u64(self) -> u64
pub const fn to_u64(self) -> u64
Convert this RID into a u64
. Returns 0 if it is invalid.
Godot equivalent: Rid.get_id()
pub const fn to_valid_u64(self) -> Option<u64>
pub const fn to_valid_u64(self) -> Option<u64>
Convert this RID into a u64
if it is valid. Otherwise, return None.
pub const fn is_invalid(&self) -> bool
pub const fn is_invalid(&self) -> bool
Returns true
if this is an invalid RID.
Trait Implementations§
§impl FromGodot for Rid
impl FromGodot for Rid
§fn try_from_godot(via: <Rid as GodotConvert>::Via) -> Result<Rid, ConvertError>
fn try_from_godot(via: <Rid as GodotConvert>::Via) -> Result<Rid, 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 Ord for Rid
impl Ord for Rid
§impl PartialOrd for Rid
impl PartialOrd for Rid
§fn partial_cmp(&self, other: &Rid) -> Option<Ordering>
fn partial_cmp(&self, other: &Rid) -> Option<Ordering>
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
self
and other
) and is used by the <=
operator. Read more§impl ToGodot for Rid
impl ToGodot for Rid
§fn to_godot(&self) -> <Rid as GodotConvert>::Via
fn to_godot(&self) -> <Rid as GodotConvert>::Via
§fn into_godot(self) -> <Rid as GodotConvert>::Via
fn into_godot(self) -> <Rid as GodotConvert>::Via
§fn to_variant(&self) -> Variant
fn to_variant(&self) -> Variant
§impl TypeStringHint for Rid
impl TypeStringHint for Rid
§fn type_string() -> String
fn type_string() -> String
§impl Var for Rid
impl Var for Rid
fn get_property(&self) -> <Rid as GodotConvert>::Via
fn set_property(&mut self, value: <Rid as GodotConvert>::Via)
fn property_hint() -> PropertyHintInfo
impl ArrayElement for Rid
impl Copy for Rid
impl Eq for Rid
impl GodotType for Rid
impl StructuralPartialEq for Rid
Auto Trait Implementations§
impl Freeze for Rid
impl RefUnwindSafe for Rid
impl Send for Rid
impl Sync for Rid
impl Unpin for Rid
impl UnwindSafe for Rid
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§default unsafe fn clone_to_uninit(&self, dst: *mut T)
default unsafe fn clone_to_uninit(&self, dst: *mut T)
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)
clone_to_uninit
)