pub struct CArc<T, TAllocator: Allocator> { /* private fields */ }Expand description
A smart pointer that can be used to share ownership of a value.
This struct is equivalent to the standard Arc type,
but is #[repr(C)] and thus safe to use across the ffi boundaries.
Implementations§
Source§impl<T, TAllocator: Allocator> CArc<T, TAllocator>
impl<T, TAllocator: Allocator> CArc<T, TAllocator>
Sourcepub fn with_allocator(
value: T,
allocator: TAllocator,
) -> Result<Self, CArcError>
pub fn with_allocator( value: T, allocator: TAllocator, ) -> Result<Self, CArcError>
Sourcepub fn strong_count(carc: &Self) -> u32
pub fn strong_count(carc: &Self) -> u32
Returns the number of strong references to the CArc.
Sourcepub fn weak_count(carc: &Self) -> u32
pub fn weak_count(carc: &Self) -> u32
Returns the number of weak references to the CArc.
Sourcepub fn downgrade(
carc: &Self,
) -> Result<CWeak<T, TAllocator>, MaxReferencesExceededError>
pub fn downgrade( carc: &Self, ) -> Result<CWeak<T, TAllocator>, MaxReferencesExceededError>
Creates a new CWeak reference to the CArc.
§Errors
If the weak reference count is too high. Cannot exceed MAX_REFERENCES.
Sourcepub fn abandon(carc: Self) -> Option<AbandonResult<T, TAllocator>>
pub fn abandon(carc: Self) -> Option<AbandonResult<T, TAllocator>>
Sourcepub const fn into_raw_ptr(carc: Self) -> *mut u8
pub const fn into_raw_ptr(carc: Self) -> *mut u8
Sourcepub const unsafe fn from_raw_ptr(ptr: *mut u8) -> Self
pub const unsafe fn from_raw_ptr(ptr: *mut u8) -> Self
Converts a raw pointer back to a CArc.
§Safety
- The caller must ensure that the pointer came from the previous
call to
CArc::into_raw_ptr. - The caller must ensure that the raw pointer won’t be used after the call.
Otherwise the behavior is undefined.
Trait Implementations§
impl<T: Eq, TAllocator: Allocator> Eq for CArc<T, TAllocator>
Source§impl<T: Ord, TAllocator: Allocator> Ord for CArc<T, TAllocator>
impl<T: Ord, TAllocator: Allocator> Ord for CArc<T, TAllocator>
Source§fn cmp(&self, other: &Self) -> CmpOrdering
fn cmp(&self, other: &Self) -> CmpOrdering
1.21.0 (const: unstable) · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the maximum of two values. Read more
Source§impl<T: PartialOrd, TAllocator: Allocator> PartialOrd for CArc<T, TAllocator>
impl<T: PartialOrd, TAllocator: Allocator> PartialOrd for CArc<T, TAllocator>
Auto Trait Implementations§
impl<T, TAllocator> Freeze for CArc<T, TAllocator>
impl<T, TAllocator> RefUnwindSafe for CArc<T, TAllocator>where
T: RefUnwindSafe,
TAllocator: RefUnwindSafe,
impl<T, TAllocator> Send for CArc<T, TAllocator>
impl<T, TAllocator> Sync for CArc<T, TAllocator>
impl<T, TAllocator> Unpin for CArc<T, TAllocator>
impl<T, TAllocator> UnsafeUnpin for CArc<T, TAllocator>
impl<T, TAllocator> UnwindSafe for CArc<T, TAllocator>where
T: UnwindSafe,
TAllocator: UnwindSafe,
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
Mutably borrows from an owned value. Read more