#[repr(C)]pub struct RefAny {
pub _internal_ptr: *const c_void,
pub sharing_info: RefCount,
pub instance_id: u64,
pub run_destructor: bool,
}Fields§
§_internal_ptr: *const c_voidvoid* to a boxed struct or enum of type “T”. RefCount stores the RTTI for this opaque type (can be downcasted by the user)
sharing_info: RefCountAll the metadata information is set on the refcount, so that the metadata has to only be created once per object, not once per copy
instance_id: u64Instance of this copy (root = 0th copy).
Necessary to distinguish between the original copy and all other clones
run_destructor: boolImplementations§
Source§impl RefAny
impl RefAny
Sourcepub fn new<T: 'static>(value: T) -> Self
pub fn new<T: 'static>(value: T) -> Self
Creates a new, type-erased pointer by casting the T value into a
Vec<u8> and saving the length + type ID
Sourcepub fn new_c(
ptr: *const c_void,
len: usize,
type_id: u64,
type_name: AzString,
custom_destructor: extern "C" fn(&mut c_void),
) -> Self
pub fn new_c( ptr: *const c_void, len: usize, type_id: u64, type_name: AzString, custom_destructor: extern "C" fn(&mut c_void), ) -> Self
C-ABI compatible function to create a RefAny across the C boundary
Sourcepub fn has_no_copies(&self) -> bool
pub fn has_no_copies(&self) -> bool
Returns whether this RefAny is the only instance
Sourcepub fn downcast_ref<'a, U: 'static>(&'a mut self) -> Option<Ref<'a, U>>
pub fn downcast_ref<'a, U: 'static>(&'a mut self) -> Option<Ref<'a, U>>
Downcasts the type-erased pointer to a type &U, returns None if the types don’t match
Sourcepub fn downcast_mut<'a, U: 'static>(&'a mut self) -> Option<RefMut<'a, U>>
pub fn downcast_mut<'a, U: 'static>(&'a mut self) -> Option<RefMut<'a, U>>
Downcasts the type-erased pointer to a type &mut U, returns None if the types don’t
match
pub fn get_type_id(&self) -> u64
pub fn get_type_name(&self) -> AzString
Trait Implementations§
Source§impl Ord for RefAny
impl Ord for RefAny
Source§impl PartialOrd for RefAny
impl PartialOrd for RefAny
impl Eq for RefAny
impl Send for RefAny
impl StructuralPartialEq for RefAny
impl Sync for RefAny
Auto Trait Implementations§
impl Freeze for RefAny
impl RefUnwindSafe for RefAny
impl Unpin for RefAny
impl UnwindSafe for RefAny
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§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more