tvm_ffi::object

Struct ObjectArc

Source
#[repr(C)]
pub struct ObjectArc<T: ObjectCore> { /* private fields */ }
Expand description

Arc-like wrapper for Object that allows shared ownership

\tparam T The type of the object to be wrapped

Implementations§

Source§

impl<T: ObjectCore> ObjectArc<T>

Source

pub fn new(data: T) -> Self

Allocate an initialized object at its stable managed address.

Source

pub fn new_with_extra_items<U>(data: T) -> Self
where T: ObjectCoreWithExtraItems<ExtraItem = U>,

Allocate a stable object followed by its type’s extra item storage.

Source

pub unsafe fn from_raw(ptr: *const T) -> Self

Move a previously allocated object into the ObjectArc

§Arguments
  • ptr - The raw pointer to move into the ObjectArc
§Returns
  • ObjectArc<T> - The ObjectArc \return The ObjectArc
§Safety

ptr must own one strong reference to a live, stable managed allocation whose dynamic type is compatible with T and whose payload is valid. Ownership of that reference is transferred into the returned handle.

Source

pub unsafe fn into_raw(this: Self) -> *const T

Move the ObjectArc into a raw pointer

§Arguments
  • this - The ObjectArc to move into a raw pointer
§Returns
  • *const T - The raw pointer
Source

pub unsafe fn as_raw(this: &Self) -> *const T

Get the raw pointer from the ObjectArc

Caller should view this as a non-owning reference

§Arguments
  • this - The ObjectArc to get the raw pointer
§Returns
  • *const T - The raw pointer \return The raw pointer
§Safety

Access must respect existing borrows, and the pointer cannot outlive an owning handle. The object and header must not be moved or replaced.

Source

pub unsafe fn as_raw_mut(this: &mut Self) -> *mut T

Get the raw mutable pointer from the ObjectArc

Caller should view this as a non-owning reference

§Arguments
  • this - The ObjectArc to get the raw pointer
§Returns
  • *mut T - The raw pointer
§Safety

The handle need not be unique. The caller must establish exclusive access for each mutation and must not move or replace the object or its header.

Source

pub fn strong_count(this: &Self) -> usize

Get the strong reference count of the ObjectArc

§Arguments
  • this - The ObjectArc to get the strong reference count
§Returns
  • usize - The strong reference count
Source

pub fn weak_count(this: &Self) -> usize

Get the weak reference count of the ObjectArc

§Arguments
  • this - The ObjectArc to get the weak reference count
§Returns
  • usize - The weak reference count

Trait Implementations§

Source§

impl<T: ObjectCore> Clone for ObjectArc<T>

Source§

fn clone(&self) -> Self

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<T: ObjectCore> Deref for ObjectArc<T>

Source§

type Target = T

The resulting type after dereferencing.
Source§

fn deref(&self) -> &Self::Target

Dereferences the value.
Source§

impl<T: ObjectCore> Drop for ObjectArc<T>

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

impl<T: Send + Sync + ObjectCore> Send for ObjectArc<T>

Source§

impl<T: Send + Sync + ObjectCore> Sync for ObjectArc<T>

Auto Trait Implementations§

§

impl<T> Freeze for ObjectArc<T>

§

impl<T> RefUnwindSafe for ObjectArc<T>
where T: RefUnwindSafe,

§

impl<T> Unpin for ObjectArc<T>
where T: Unpin,

§

impl<T> UnwindSafe for ObjectArc<T>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dst: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

Source§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.