pub trait TypedUserdataAccess: Sealed {
// Required methods
unsafe fn typed_userdata(&self, userdata: Userdata) -> Option<TypedUserdata>;
unsafe fn typed_userdata_at(&self, index: i32) -> Option<TypedUserdata>;
unsafe fn push_typed_userdata<T: 'static>(
&self,
value: T,
registration: &UserdataTypeRegistration,
) -> VmErrorResult;
unsafe fn typed_userdata_value(&self, userdata: TypedUserdata) -> TValue;
unsafe fn set_typed_userdata_value(
&self,
userdata: TypedUserdata,
value: TValue,
);
unsafe fn take_typed_userdata<T: 'static>(
&self,
userdata: TypedUserdata,
) -> Result<T, TypedUserdataError>;
unsafe fn destroy_typed_userdata(
&self,
userdata: TypedUserdata,
) -> Result<(), TypedUserdataError>;
}Expand description
Unstable access capability for registered Rust userdata.
This provides the storage and validation mechanics used by VM-native callbacks and higher-level embedding layers; it does not root returned userdata descriptors.
§Safety
The thread and registration must be live and belong to the same VM. Stack indices must be valid. Returned descriptors do not root their userdata; callers must keep the object rooted and must not replace its registered metatable or replace its payload while a descriptor or borrow remains live. The lifecycle operations require exclusive payload access. They remove the Rust payload but leave the associated value slot intact. Values returned from that slot are non-owning VM views and remain valid only while their userdata and referenced object remain live.
Required Methods§
unsafe fn typed_userdata(&self, userdata: Userdata) -> Option<TypedUserdata>
unsafe fn typed_userdata_at(&self, index: i32) -> Option<TypedUserdata>
unsafe fn push_typed_userdata<T: 'static>( &self, value: T, registration: &UserdataTypeRegistration, ) -> VmErrorResult
unsafe fn typed_userdata_value(&self, userdata: TypedUserdata) -> TValue
unsafe fn set_typed_userdata_value( &self, userdata: TypedUserdata, value: TValue, )
unsafe fn take_typed_userdata<T: 'static>( &self, userdata: TypedUserdata, ) -> Result<T, TypedUserdataError>
unsafe fn destroy_typed_userdata( &self, userdata: TypedUserdata, ) -> Result<(), TypedUserdataError>
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".