Enum Rid
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.
§Godot docs
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 ArrayElement for Rid
impl ArrayElement for Rid
fn debug_validate_elements(_array: &Array<Self>) -> Result<(), ConvertError>
§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
§impl ToGodot for Rid
impl ToGodot for Rid
§type ToVia<'v> = <Rid as GodotConvert>::Via
type ToVia<'v> = <Rid as GodotConvert>::Via
to_godot()
, which differs from Via
for pass-by-reference types.§fn to_godot(&self) -> <Rid as ToGodot>::ToVia<'_>
fn to_godot(&self) -> <Rid as ToGodot>::ToVia<'_>
§fn to_variant(&self) -> Variant
fn to_variant(&self) -> Variant
§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 var_hint() -> PropertyHintInfo
fn var_hint() -> PropertyHintInfo
GodotType::property_info
, e.g. for enums/newtypes.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§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)