[][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]

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

Returns the number of hard references to the shared resident.

Returns the number of soft references to the shared resident.

Returns the number of immutable references to the shared resident.

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

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

Returns a mutable lease to a clone of the shared resident

Panics

Panics on allocation failure.

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.

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.

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.

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

Returns a new hard lease to the shared resident.

Panics

Panics if the incremented hard reference count overflows HARD_COUNT_MAX.

Converts this immutable lease into a hard lease.

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

Returns a new soft reference to the shared resident.

Panics

Panics if the incremented soft reference count overflows SOFT_COUNT_MAX.

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.

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

Panics

Panics if the incremented soft reference count overflows SOFT_COUNT_MAX.

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.

Returns a raw pointer to the shared resident.

Safety

The shared resident may be uninitialized, or mutably aliased.

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.

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][+]

Compares and returns the maximum of two values. Read more

Compares and returns the minimum of two values. Read more

🔬 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][+]

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][+]

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][]