Struct ffi_support::handle_map::HandleMap [−][src]
pub struct HandleMap<T> { /* fields omitted */ }
Expand description
HandleMap
is a collection type which can hold any type of value, and
offers a stable handle which can be used to retrieve it on insertion. These
handles offer methods for converting to and
from 64 bit integers, meaning they’re very easy to pass
over the FFI (they also implement IntoFfi
for the same purpose).
See the module level docs for more information.
Note: In FFI code, most usage of HandleMap
will be done through the
ConcurrentHandleMap
type, which is a thin wrapper around a
RwLock<HandleMap<Mutex<T>>>
.
Implementations
impl<T> HandleMap<T>
[src]
impl<T> HandleMap<T>
[src]pub fn new_with_capacity(request: usize) -> Self
[src]
pub fn new_with_capacity(request: usize) -> Self
[src]Allocate a new HandleMap
. Note that the actual capacity may be larger
than the requested value.
Panics if request
is greater than handle_map::MAX_CAPACITY
pub fn insert(&mut self, v: T) -> Handle
[src]
pub fn insert(&mut self, v: T) -> Handle
[src]Insert an item into the map, and return a handle to it.
pub fn delete(&mut self, h: Handle) -> Result<(), HandleError>
[src]
pub fn delete(&mut self, h: Handle) -> Result<(), HandleError>
[src]Delete an item from the HandleMap.
pub fn remove(&mut self, h: Handle) -> Result<T, HandleError>
[src]
pub fn remove(&mut self, h: Handle) -> Result<T, HandleError>
[src]Remove an item from the HandleMap, returning the old value.
pub fn get(&self, h: Handle) -> Result<&T, HandleError>
[src]
pub fn get(&self, h: Handle) -> Result<&T, HandleError>
[src]Get a reference to the item referenced by the handle, or return a
HandleError
describing the problem.
pub fn get_mut(&mut self, h: Handle) -> Result<&mut T, HandleError>
[src]
pub fn get_mut(&mut self, h: Handle) -> Result<&mut T, HandleError>
[src]Get a mut reference to the item referenced by the handle, or return a
HandleError
describing the problem.
Trait Implementations
Auto Trait Implementations
impl<T> RefUnwindSafe for HandleMap<T> where
T: RefUnwindSafe,
T: RefUnwindSafe,
impl<T> Send for HandleMap<T> where
T: Send,
T: Send,
impl<T> Sync for HandleMap<T> where
T: Sync,
T: Sync,
impl<T> Unpin for HandleMap<T> where
T: Unpin,
T: Unpin,
impl<T> UnwindSafe for HandleMap<T> where
T: UnwindSafe,
T: UnwindSafe,
Blanket Implementations
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]pub fn borrow_mut(&mut self) -> &mut T
[src]
pub fn borrow_mut(&mut self) -> &mut T
[src]Mutably borrows from an owned value. Read more
impl<T> ToOwned for T where
T: Clone,
[src]
impl<T> ToOwned for T where
T: Clone,
[src]type Owned = T
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn to_owned(&self) -> T
[src]Creates owned data from borrowed data, usually by cloning. Read more
pub fn clone_into(&self, target: &mut T)
[src]
pub fn clone_into(&self, target: &mut T)
[src]🔬 This is a nightly-only experimental API. (toowned_clone_into
)
recently added
Uses borrowed data to replace owned data, usually by cloning. Read more