Module aref

Source
Expand description

Internal reference counting support.

Many C types already have their own reference counting mechanism (e.g. by storing a refcount_t). This module provides support for directly using their internal reference count from Rust; instead of making users have to use an additional Rust-reference count in the form of Arc.

The smart pointer ARef<T> acts similarly to Arc<T> in that it holds a refcount on the underlying object, but this refcount is internal to the object. It essentially is a Rust implementation of the get_ and put_ pattern used in C for reference counting.

To make use of ARef<MyType>, MyType needs to implement AlwaysRefCounted. It is a trait for accessing the internal reference count of an object of the MyType type.

Structs§

ARef
An owned reference to an always-reference-counted object.

Traits§

AlwaysRefCounted
Types that are always reference counted.