[][src]Struct swim_mem::lease::Ref

pub struct Ref<'a, R: Resident> { /* fields omitted */ }

A thread-safe, atomically counted, immutably dereferenceable hard reference to a Resident occupying a shared, Hold-allocated memory block.

Methods

impl<'a, R: Resident> Ref<'a, R>[src]

pub fn try_hold_new_meta<T, M>(
    hold: &dyn Hold<'a>,
    data: T,
    meta: M
) -> Result<Ref<'a, R>, HoldError> where
    R: ResidentFromValue<Ref<'a, R>, T, M>, 
[src]

pub fn try_hold_clone_meta<T: ?Sized, M>(
    hold: &dyn Hold<'a>,
    data: &T,
    meta: M
) -> Result<Ref<'a, R>, HoldError> where
    R: ResidentFromClone<Ref<'a, R>, T, M>, 
[src]

pub unsafe fn try_hold_clone_unchecked_meta<T: ?Sized, M>(
    hold: &dyn Hold<'a>,
    data: &T,
    meta: M
) -> Result<Ref<'a, R>, HoldError> where
    R: ResidentFromCloneUnchecked<Ref<'a, R>, T, M>, 
[src]

pub fn try_hold_copy_meta<T: ?Sized, M>(
    hold: &dyn Hold<'a>,
    data: &T,
    meta: M
) -> Result<Ref<'a, R>, HoldError> where
    R: ResidentFromCopy<Ref<'a, R>, T, M>, 
[src]

pub unsafe fn try_hold_copy_unchecked_meta<T: ?Sized, M>(
    hold: &dyn Hold<'a>,
    data: &T,
    meta: M
) -> Result<Ref<'a, R>, HoldError> where
    R: ResidentFromCopyUnchecked<Ref<'a, R>, T, M>, 
[src]

pub fn try_hold_empty_meta<M>(
    hold: &dyn Hold<'a>,
    meta: M
) -> Result<Ref<'a, R>, HoldError> where
    R: ResidentFromEmpty<Ref<'a, R>, M>, 
[src]

pub fn try_hold_cap_meta<M>(
    hold: &dyn Hold<'a>,
    cap: usize,
    meta: M
) -> Result<Ref<'a, R>, HoldError> where
    R: ResidentWithCapacity<Ref<'a, R>, M>, 
[src]

pub fn try_hold_new<T>(
    hold: &dyn Hold<'a>,
    data: T
) -> Result<Ref<'a, R>, HoldError> where
    R: ResidentFromValue<Ref<'a, R>, T>, 
[src]

pub fn try_hold_clone<T: ?Sized>(
    hold: &dyn Hold<'a>,
    data: &T
) -> Result<Ref<'a, R>, HoldError> where
    R: ResidentFromClone<Ref<'a, R>, T>, 
[src]

pub unsafe fn try_hold_clone_unchecked<T: ?Sized>(
    hold: &dyn Hold<'a>,
    data: &T
) -> Result<Ref<'a, R>, HoldError> where
    R: ResidentFromCloneUnchecked<Ref<'a, R>, T>, 
[src]

pub fn try_hold_copy<T: ?Sized>(
    hold: &dyn Hold<'a>,
    data: &T
) -> Result<Ref<'a, R>, HoldError> where
    R: ResidentFromCopy<Ref<'a, R>, T>, 
[src]

pub unsafe fn try_hold_copy_unchecked<T: ?Sized>(
    hold: &dyn Hold<'a>,
    data: &T
) -> Result<Ref<'a, R>, HoldError> where
    R: ResidentFromCopyUnchecked<Ref<'a, R>, T>, 
[src]

pub fn try_hold_empty(hold: &dyn Hold<'a>) -> Result<Ref<'a, R>, HoldError> where
    R: ResidentFromEmpty<Ref<'a, R>>, 
[src]

pub fn try_hold_cap(
    hold: &dyn Hold<'a>,
    cap: usize
) -> Result<Ref<'a, R>, HoldError> where
    R: ResidentWithCapacity<Ref<'a, R>>, 
[src]

pub fn hold_new<T>(hold: &dyn Hold<'a>, data: T) -> Ref<'a, R> where
    R: ResidentFromValue<Ref<'a, R>, T>, 
[src]

pub fn hold_clone<T: ?Sized>(hold: &dyn Hold<'a>, data: &T) -> Ref<'a, R> where
    R: ResidentFromClone<Ref<'a, R>, T>, 
[src]

pub unsafe fn hold_clone_unchecked<T: ?Sized>(
    hold: &dyn Hold<'a>,
    data: &T
) -> Ref<'a, R> where
    R: ResidentFromCloneUnchecked<Ref<'a, R>, T>, 
[src]

pub fn hold_copy<T: ?Sized>(hold: &dyn Hold<'a>, data: &T) -> Ref<'a, R> where
    R: ResidentFromCopy<Ref<'a, R>, T>, 
[src]

pub unsafe fn hold_copy_unchecked<T: ?Sized>(
    hold: &dyn Hold<'a>,
    data: &T
) -> Ref<'a, R> where
    R: ResidentFromCopyUnchecked<Ref<'a, R>, T>, 
[src]

pub fn hold_empty(hold: &dyn Hold<'a>) -> Ref<'a, R> where
    R: ResidentFromEmpty<Ref<'a, R>>, 
[src]

pub fn hold_cap(hold: &dyn Hold<'a>, cap: usize) -> Ref<'a, R> where
    R: ResidentWithCapacity<Ref<'a, R>>, 
[src]

pub fn new<T>(data: T) -> Ref<'a, R> where
    R: ResidentFromValue<Ref<'a, R>, T>, 
[src]

pub fn from_clone<T: ?Sized>(data: &T) -> Ref<'a, R> where
    R: ResidentFromClone<Ref<'a, R>, T>, 
[src]

pub unsafe fn from_clone_unchecked<T: ?Sized>(data: &T) -> Ref<'a, R> where
    R: ResidentFromCloneUnchecked<Ref<'a, R>, T>, 
[src]

pub fn from_copy<T: ?Sized>(data: &T) -> Ref<'a, R> where
    R: ResidentFromCopy<Ref<'a, R>, T>, 
[src]

pub unsafe fn from_copy_unchecked<T: ?Sized>(data: &T) -> Ref<'a, R> where
    R: ResidentFromCopyUnchecked<Ref<'a, R>, T>, 
[src]

pub fn empty() -> Ref<'a, R> where
    R: ResidentFromEmpty<Ref<'a, R>>, 
[src]

pub fn with_cap(cap: usize) -> Ref<'a, R> where
    R: ResidentWithCapacity<Ref<'a, R>>, 
[src]

pub unsafe fn from_raw(data: *mut R::Data) -> Ref<'a, R>[src]

Constructs a Ref lease from a raw pointer returned by Ref::into_raw.

pub fn hard_count(this: &Ref<'a, R>) -> usize[src]

Returns the number of hard references to the shared resident.

pub fn soft_count(this: &Ref<'a, R>) -> usize[src]

Returns the number of soft references to the shared resident.

pub fn ref_count(this: &Ref<'a, R>) -> usize[src]

Returns the number of immutable references to the shared resident.

pub fn metadata<'b>(this: &'b Ref<'a, R>) -> &'b R::Meta[src]

Returns a reference to the user-provided metadata associated with the shared resident.

pub fn try_to_unique(this: &Ref<'a, R>) -> Result<Mut<'a, R>, ArcError> where
    R::Data: TryClone,
    R::Meta: TryClone
[src]

Returns a mutable lease to a clone of the shared resident, returning an error on allocation failure.

pub fn to_unique(this: &Ref<'a, R>) -> Mut<'a, R> where
    R::Data: TryClone,
    R::Meta: TryClone
[src]

Returns a mutable lease to a clone of the shared resident

Panics

Panics on allocation failure.

pub fn try_into_unique(this: Ref<'a, R>) -> Result<Mut<'a, R>, ArcError> where
    R::Data: TryClone,
    R::Meta: TryClone
[src]

Converts this immutable lease into a mutable lease to the shared resident, cloning the resident if there are any outstanding mutable or immutable leases, and returning an error on allocation failure.

pub fn into_unique(this: Ref<'a, R>) -> Mut<'a, R> where
    R::Data: TryClone,
    R::Meta: TryClone
[src]

Converts this immutable lease into a mutable lease to the shared resident, cloning the resident if there are any outstanding mutable or immutable leases.

Panics

Panics on allocation failure.

pub unsafe fn into_mut(this: Ref<'a, R>) -> Mut<'a, R>[src]

Converts this immutable lease into a mutable lease to the shared resident, waiting for any outstanding mutable or immutable leases to drop.

Safety

Deadlocks if the current thread already holds a mutable or immutable lease to the shared resident. Can cause a future deadlock if a thread holding a mutable lease to a resident attempts to convert another hard or soft lease to the same resident into a mutable or immutable lease.

pub fn try_to_hard(this: &Ref<'a, R>) -> Result<Hard<'a, R>, ArcError>[src]

Returns a new hard lease to the shared resident, returning an error if the incremented hard reference count overflows HARD_COUNT_MAX.

pub fn to_hard(this: &Ref<'a, R>) -> Hard<'a, R>[src]

Returns a new hard lease to the shared resident.

Panics

Panics if the incremented hard reference count overflows HARD_COUNT_MAX.

pub fn into_hard(this: Ref<'a, R>) -> Hard<'a, R>[src]

Converts this immutable lease into a hard lease.

pub fn try_to_soft(this: &Ref<'a, R>) -> Result<Soft<'a, R>, ArcError>[src]

Returns a new soft reference to the shared resident, returning an error if the incremented soft reference count overflows SOFT_COUNT_MAX.

pub fn to_soft(this: &Ref<'a, R>) -> Soft<'a, R>[src]

Returns a new soft reference to the shared resident.

Panics

Panics if the incremented soft reference count overflows SOFT_COUNT_MAX.

pub fn try_into_soft(this: Ref<'a, R>) -> Result<Soft<'a, R>, ArcError>[src]

Converts this immutable lease into a soft lease to the shared resident, returning an error if the incremented soft reference count overflows SOFT_COUNT_MAX.

pub fn into_soft(this: Ref<'a, R>) -> Soft<'a, R>[src]

Converts this immutable lease into a soft lease to the shared resident.

Panics

Panics if the incremented soft reference count overflows SOFT_COUNT_MAX.

pub unsafe fn into_raw(this: Ref<'a, R>) -> *mut R::Data[src]

Converts this immutable lease into a raw pointer to the shared resident. Use Ref::from_raw to reconstitute the returned pointer back into an immutable lease.

Safety

A memory leak will occur unless the returned pointer is eventually converted back into an immutable lease and dropped.

pub unsafe fn as_ptr_unchecked(this: &Ref<'a, R>) -> *mut R::Data[src]

Returns a raw pointer to the shared resident.

Safety

The shared resident may be uninitialized, or mutably aliased.

pub fn try_unwrap(this: Ref<'a, R>) -> Result<R::Target, Ref<'a, R>> where
    R: ResidentUnwrap<Ref<'a, R>>, 
[src]

Consumes this immutable lease, and returns the shared resident; returns an Err containing the original lease if any outstanding hard or immutable leases prevent the resident from being moved.

pub fn unwrap(this: Ref<'a, R>) -> R::Target where
    R: ResidentUnwrap<Ref<'a, R>>, 
[src]

Consumes this immutable lease, and returns the shared resident.

Panics

Panics if any outstanding hard or immutable leases prevent the resident from being moved.

Trait Implementations

impl<'a, R: Resident> Holder<'a> for Ref<'a, R>[src]

impl<'a, R: Resident> TryClone for Ref<'a, R>[src]

impl<'a, R: Resident> Lease for Ref<'a, R>[src]

type Data = R::Data

The type of pointed-to data stored in leased memory blocks. The size of leased memory blocks must be a positive multiple of the Data size. Read more

type Meta = R::Meta

The type of metadata stored with leased memory blocks. Meta data must contain sufficient information to resolve the size of any resided-in memory Lease. Read more

impl<'a, R: ResidentPartialEq<Ref<'a, R>, T>, T: ?Sized> PartialEq<T> for Ref<'a, R>[src]

impl<'a, R: ResidentEq<Ref<'a, R>>> Eq for Ref<'a, R>[src]

impl<'a, R: ResidentOrd<Ref<'a, R>>> Ord for Ref<'a, R>[src]

default fn max(self, other: Self) -> Self
1.21.0
[src]

Compares and returns the maximum of two values. Read more

default fn min(self, other: Self) -> Self
1.21.0
[src]

Compares and returns the minimum of two values. Read more

default fn clamp(self, min: Self, max: Self) -> Self[src]

🔬 This is a nightly-only experimental API. (clamp)

Restrict a value to a certain interval. Read more

impl<'a, R: ResidentPartialOrd<Ref<'a, R>, T>, T: ?Sized> PartialOrd<T> for Ref<'a, R>[src]

impl<'a, R: ResidentDeref<Ref<'a, R>>> Deref for Ref<'a, R>[src]

type Target = R::Target

The resulting type after dereferencing.

impl<'a, R: ResidentDisplay<Ref<'a, R>>> Display for Ref<'a, R>[src]

impl<'a, R: ResidentDebug<Ref<'a, R>>> Debug for Ref<'a, R>[src]

impl<'a, R: ResidentAdd<Ref<'a, R>, Rhs>, Rhs> Add<Rhs> for Ref<'a, R>[src]

type Output = R::Output

The resulting type after applying the + operator.

impl<'a, R: Resident> Drop for Ref<'a, R>[src]

impl<'a, R: ResidentIndex<Ref<'a, R>, Idx>, Idx> Index<Idx> for Ref<'a, R>[src]

type Output = R::Output

The returned type after indexing.

impl<'a, R: ResidentHash<Ref<'a, R>>> Hash for Ref<'a, R>[src]

default fn hash_slice<H>(data: &[Self], state: &mut H) where
    H: Hasher
1.3.0
[src]

Feeds a slice of this type into the given [Hasher]. Read more

impl<'a, R: Resident> Sync for Ref<'a, R> where
    R::Data: Sync,
    R::Meta: Sync
[src]

impl<'a, R: ResidentIntoIterator<Ref<'a, R>>> IntoIterator for Ref<'a, R>[src]

type Item = R::Item

The type of the elements being iterated over.

type IntoIter = R::IntoIter

Which kind of iterator are we turning this into?

impl<'a, R: ResidentIntoRefIterator<'a, Ref<'a, R>>> IntoIterator for &'a Ref<'a, R>[src]

type Item = R::Item

The type of the elements being iterated over.

type IntoIter = R::IntoIter

Which kind of iterator are we turning this into?

impl<'a, R: Resident> Send for Ref<'a, R> where
    R::Data: Send,
    R::Meta: Send
[src]

impl<'a, R: Resident> Pointer for Ref<'a, R>[src]

impl<'a, R: Resident> Clone for Ref<'a, R>[src]

default fn clone_from(&mut self, source: &Self)
1.0.0
[src]

Performs copy-assignment from source. Read more

impl<'a, R: ResidentAsRef<Ref<'a, R>, T>, T: ?Sized> AsRef<T> for Ref<'a, R>[src]

Blanket Implementations

impl<T> From for T[src]

impl<I> IntoIterator for I where
    I: Iterator
[src]

type Item = <I as Iterator>::Item

The type of the elements being iterated over.

type IntoIter = I

Which kind of iterator are we turning this into?

impl<T, U> TryFrom for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<T, U> Into for T where
    U: From<T>, 
[src]

impl<T> Borrow for T where
    T: ?Sized
[src]

impl<T> BorrowMut for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]