Skip to main content

ObjectArc

Struct ObjectArc 

Source
pub struct ObjectArc<T: ObjectCore> { /* private fields */ }
Expand description

A reference-counted pointer to an object T, as Arc<T>, counting with the object header so that every language shares the count.

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 unsafe 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.

§Safety

The extra items start uninitialized: the caller writes each of them, through ObjectCoreWithExtraItems::extra_items_ptr of as_mut_ptr, before the object is read or shared.

Source

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

Take ownership of a raw object pointer, as Arc::from_raw.

§Arguments
  • ptr - A pointer that owns one strong reference.
§Returns

The handle that owns that reference.

§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 fn into_raw(this: Self) -> *const T

Turn the handle into a raw pointer, as Arc::into_raw.

§Arguments
  • this - The handle.
§Returns

The pointer, which owns the strong reference; pass it back to ObjectArc::from_raw to release it.

Source

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

The raw pointer, without giving up ownership, as Arc::as_ptr.

§Arguments
  • this - The handle.
§Returns

The non-owning pointer. Dereferencing it must respect existing borrows, and it cannot outlive an owning handle.

Source

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

The raw mutable pointer, without giving up ownership.

§Arguments
  • this - The handle.
§Returns

The non-owning pointer. The handle need not be unique: writing through it needs exclusive access to the object, and must not move or replace the object or its header.

Source

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

The number of strong references, as Arc::strong_count.

§Arguments
  • this - The handle.
Source

pub fn is_unique(this: &Self) -> bool

Whether this is the only reference, strong and with no weak one, so the object may be mutated in place.

§Arguments
  • this - The handle.
Source

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

The number of weak references, as Arc::weak_count: the weak reference that the strong references hold together is not counted.

§Arguments
  • this - The handle.

Trait Implementations§

Source§

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

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · 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§

fn pin_drop(self: Pin<&mut Self>)

🔬This is a nightly-only experimental API. (pin_ergonomics)
Execute the destructor for this type, but different to Drop::drop, it requires self to be pinned. Read more
Source§

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

Source§

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

Auto Trait Implementations§

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, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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 = !

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

fn try_from(value: U) -> Result<T, !>

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.
Source§

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