pub struct ResourceArc<T> where
    T: ResourceTypeProvider, 
{ /* private fields */ }
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

Makes a new ResourceArc from the given type. Note that the type must have ResourceTypeProvider implemented for it. See module documentation for info on this.

Trait Implementations

Cloning a ResourceArc simply increments the reference count for the resource. The T value is not cloned.

Performs copy-assignment from source. Read more

The resulting type after dereferencing.

Dereferences the value.

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

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

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

The resulting type after obtaining ownership.

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

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

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.