pub trait Storage<T>:
Send
+ Sync
+ 'static {
type Wrapped: StorageAccess<T> + Send + Sync + 'static;
// Required methods
fn wrap(value: T) -> Self::Wrapped;
fn try_with<U>(node: NodeId, fun: impl FnOnce(&T) -> U) -> Option<U>;
fn try_with_mut<U>(node: NodeId, fun: impl FnOnce(&mut T) -> U) -> Option<U>;
fn try_set(node: NodeId, value: T) -> Option<T>;
fn take(node: NodeId) -> Option<T>;
}Expand description
A way of storing an ArenaItem, either as itself or with a wrapper to make it threadsafe.
This exists because all items stored in the arena must be Send + Sync, but in single-threaded
environments you might want or need to use thread-unsafe types.
Required Associated Types§
Sourcetype Wrapped: StorageAccess<T> + Send + Sync + 'static
type Wrapped: StorageAccess<T> + Send + Sync + 'static
The type being stored, once it has been wrapped.
Required Methods§
Sourcefn try_with<U>(node: NodeId, fun: impl FnOnce(&T) -> U) -> Option<U>
fn try_with<U>(node: NodeId, fun: impl FnOnce(&T) -> U) -> Option<U>
Applies the given function to the stored value, if it exists and can be accessed from this thread.
Sourcefn try_with_mut<U>(node: NodeId, fun: impl FnOnce(&mut T) -> U) -> Option<U>
fn try_with_mut<U>(node: NodeId, fun: impl FnOnce(&mut T) -> U) -> Option<U>
Applies the given function to a mutable reference to the stored value, if it exists and can be accessed from this thread.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.