[−][src]Struct rustler::resource::ResourceArc
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
.
Methods
impl<T> ResourceArc<T> where
T: ResourceTypeProvider,
[src]
T: ResourceTypeProvider,
pub fn new(data: T) -> Self
[src]
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
impl<T> Clone for ResourceArc<T> where
T: ResourceTypeProvider,
[src]
T: ResourceTypeProvider,
fn clone(&self) -> Self
[src]
Cloning a ResourceArc
simply increments the reference count for the
resource. The T
value is not cloned.
fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl<'a, T> Decoder<'a> for ResourceArc<T> where
T: ResourceTypeProvider + 'a,
[src]
T: ResourceTypeProvider + 'a,
impl<T> Deref for ResourceArc<T> where
T: ResourceTypeProvider,
[src]
T: ResourceTypeProvider,
impl<T> Drop for ResourceArc<T> where
T: ResourceTypeProvider,
[src]
T: ResourceTypeProvider,
fn drop(&mut self)
[src]
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.
impl<T> Encoder for ResourceArc<T> where
T: ResourceTypeProvider,
[src]
T: ResourceTypeProvider,
impl<T> Send for ResourceArc<T> where
T: ResourceTypeProvider,
[src]
T: ResourceTypeProvider,
impl<T> Sync for ResourceArc<T> where
T: ResourceTypeProvider,
[src]
T: ResourceTypeProvider,
Auto Trait Implementations
impl<T> RefUnwindSafe for ResourceArc<T> where
T: RefUnwindSafe,
T: RefUnwindSafe,
impl<T> Unpin for ResourceArc<T>
impl<T> UnwindSafe for ResourceArc<T> where
T: RefUnwindSafe,
T: RefUnwindSafe,
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,