Struct rustler::resource::ResourceArc [−][src]
pub struct ResourceArc<T> where
T: ResourceTypeProvider, { /* fields omitted */ }
Expand description
A reference to a resource of type T
.
This type is like std::sync::Arc
: it provides thread-safe, reference-counted storage for Rust
data that can be shared across threads. Data stored this way is immutable by default. If you
need to modify data in a resource, use a std::sync::Mutex
or RwLock
.
Rust code and Erlang code can both have references to the same resource at the same time. Rust
code uses ResourceArc
; in Erlang, a reference to a resource is a kind of term. You can
convert back and forth between the two using Encoder
and Decoder
.
Implementations
Trait Implementations
When a ResourceArc
is dropped, the reference count is decremented. If
there are no other references to the resource, the T
value is dropped.
However, note that in general, the Rust value in a resource is dropped at an unpredictable time: whenever the VM decides to do garbage collection.
Auto Trait Implementations
impl<T> RefUnwindSafe for ResourceArc<T> where
T: RefUnwindSafe,
impl<T> Unpin for ResourceArc<T>
impl<T> UnwindSafe for ResourceArc<T> where
T: RefUnwindSafe,
Blanket Implementations
Mutably borrows from an owned value. Read more