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§
Source§impl Rid
impl Rid
Sourcepub 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()
Sourcepub 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.
Sourcepub const fn is_invalid(&self) -> bool
pub const fn is_invalid(&self) -> bool
Returns true if this is an invalid RID.
Trait Implementations§
Source§impl DynamicSend for Rid
impl DynamicSend for Rid
Source§impl FromGodot for Rid
impl FromGodot for Rid
Source§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.Source§fn from_godot(via: Self::Via) -> Self
fn from_godot(via: Self::Via) -> Self
Source§fn try_from_variant(variant: &Variant) -> Result<Self, ConvertError>
fn try_from_variant(variant: &Variant) -> Result<Self, ConvertError>
Variant, returning Err on failure.Source§impl GodotConvert for Rid
impl GodotConvert for Rid
Source§impl IntoDynamicSend for Rid
impl IntoDynamicSend for Rid
type Target = Rid
fn into_dynamic_send(self) -> <Rid as IntoDynamicSend>::Target
Source§impl Ord for Rid
impl Ord for Rid
Source§impl PartialOrd for Rid
impl PartialOrd for Rid
Source§impl ToGodot for Rid
impl ToGodot for Rid
Source§type Pass = ByValue
type Pass = ByValue
Source§fn to_godot(&self) -> <Rid as GodotConvert>::Via
fn to_godot(&self) -> <Rid as GodotConvert>::Via
Source§fn to_godot_owned(&self) -> Self::Via
fn to_godot_owned(&self) -> Self::Via
Source§fn to_variant(&self) -> Variant
fn to_variant(&self) -> Variant
Source§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)
Source§fn var_hint() -> PropertyHintInfo
fn var_hint() -> PropertyHintInfo
GodotType::property_info, e.g. for enums/newtypes.