Struct ReadHandle

Source
pub struct ReadHandle<K, V, S = RandomState> { /* private fields */ }
Expand description

A read handle for the map.

This type allows for the creation of ReadGuards, which provide immutable access to the underlying data.

Implementations§

Source§

impl<K, V, S> ReadHandle<K, V, S>

Source

pub fn guard(&self) -> View<ReadGuard<'_, K, V, S>>

Creates a new ReadGuard wrapped in a View, allowing safe access to the map.

§Examples
let (write, read) = flashmap::new::<u32, u32>();

let guard = read.guard();

// The map should be empty since we added nothing to it.
assert!(guard.is_empty());

// Maybe do some more work with the guard

// The guard is released when dropped (you don't have to drop it explicitly)
drop(guard);

In order to see the most recent updates from the writer, a new guard needs to be created:

let (mut write, read) = flashmap::new::<String, String>();

let guard = read.guard();

// This key is not in the map yet
assert!(!guard.contains_key("ferris"));

write.guard().insert("ferris".to_owned(), "crab".to_owned());

// Since we're still using the same guard, the write isn't visible to us yet
assert!(!guard.contains_key("ferris"));

// Drop the old guard and get a new one
drop(guard);
let guard = read.guard();

// The write is now visible
assert_eq!(guard.get("ferris").unwrap(), "crab");

Trait Implementations§

Source§

impl<K, V, S> Clone for ReadHandle<K, V, S>

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<K, V, S> Drop for ReadHandle<K, V, S>

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

impl<K, V, S> Send for ReadHandle<K, V, S>
where K: Send + Sync, V: Send + Sync, S: Send + Sync,

Source§

impl<K, V, S> Sync for ReadHandle<K, V, S>
where K: Send + Sync, V: Send + Sync, S: Send + Sync,

Auto Trait Implementations§

§

impl<K, V, S> Freeze for ReadHandle<K, V, S>

§

impl<K, V, S = RandomState> !RefUnwindSafe for ReadHandle<K, V, S>

§

impl<K, V, S> Unpin for ReadHandle<K, V, S>

§

impl<K, V, S = RandomState> !UnwindSafe for ReadHandle<K, V, S>

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

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

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.