Skip to main content

Ref

Struct Ref 

Source
pub struct Ref<K, V>
where K: Eq + Hash,
{ /* private fields */ }
Expand description

A guarded pointer to a cache Entry.

EntryRef provides safe access to an entry stored in the Clock cache. It binds the entry’s memory location to an epoch Guard, ensuring the entry is not reclaimed by the cache’s eviction policy while this handle exists.

Because it acts as a smart pointer to the Entry container rather than the value itself, it provides methods to access both the key and the value.

Implementations§

Source§

impl<K, V> Ref<K, V>
where K: Eq + Hash,

Source

pub fn key(&self) -> &K

Returns a shared reference to the entry’s key.

Source

pub fn value(&self) -> &V

Returns a shared reference to the entry’s value.

Source

pub fn is_expired(&self) -> bool

Returns true if the underlying entry has passed its expiration deadline.

Methods from Deref<Target = Entry<K, V>>§

Source

pub fn key(&self) -> &Key<K>

Returns a reference to the entry’s Key.

Source

pub fn value(&self) -> &V

Returns a reference to the stored value.

Source

pub fn is_expired(&self) -> bool

Checks if the entry has passed its expiration deadline.

Returns true if expired_at is a time in the past relative to Instant::now. If no expiration was set, this always returns false.

Trait Implementations§

Source§

impl<K, V: Debug> Debug for Ref<K, V>
where K: Eq + Hash + Debug,

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<K, V> Deref for Ref<K, V>
where K: Eq + Hash,

Source§

type Target = Entry<K, V>

The resulting type after dereferencing.
Source§

fn deref(&self) -> &Self::Target

Dereferences the value.

Auto Trait Implementations§

§

impl<K, V> Freeze for Ref<K, V>

§

impl<K, V> !RefUnwindSafe for Ref<K, V>

§

impl<K, V> !Send for Ref<K, V>

§

impl<K, V> !Sync for Ref<K, V>

§

impl<K, V> Unpin for Ref<K, V>

§

impl<K, V> UnsafeUnpin for Ref<K, V>

§

impl<K, V> !UnwindSafe for Ref<K, V>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

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

Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

Source§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

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

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V