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 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 ParamType for Rid
impl ParamType for Rid
§fn owned_to_arg<'v>(self) -> <Rid as ParamType>::Arg<'v>
fn owned_to_arg<'v>(self) -> <Rid as ParamType>::Arg<'v>
impl AsArg<T>
. Read more§impl PartialOrd for Rid
impl PartialOrd for Rid
§impl ToGodot for Rid
impl ToGodot for Rid
§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.