pub unsafe trait ObjectRefCore: Sized + Clone {
type ContainerType: ObjectCore;
// Required methods
fn data(this: &Self) -> &ObjectArc<Self::ContainerType>;
fn into_data(this: Self) -> ObjectArc<Self::ContainerType>;
fn from_data(data: ObjectArc<Self::ContainerType>) -> Self;
}Expand description
Traits to specify core operations of ObjectRef
used by the ffi Any system and not user facing
We mark as unsafe since it moves out the internal of the ObjectRef
§Safety
data, into_data, and from_data must preserve the same object
allocation and form an ownership-preserving round trip. That allocation must
start with a valid TVMFFIObject header whose registered object-range
runtime type index correctly describes its layout and inheritance.
When Self also implements AnyCompatible, copy_to_any_view must
produce a non-owning view, while move_to_any must transfer ownership of
the same object pointer and dynamic type index. move_from_any_after_check
must be able to reclaim that owned representation exactly once, and a true
check_any_strict result must guarantee that both after-check constructors
are valid for it.
Required Associated Types§
Required Methods§
fn data(this: &Self) -> &ObjectArc<Self::ContainerType>
fn into_data(this: Self) -> ObjectArc<Self::ContainerType>
fn from_data(data: ObjectArc<Self::ContainerType>) -> Self
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.