pub struct MemoryStorage { /* private fields */ }Expand description
In-memory storage backend (no persistence)
Stores data in a HashMap in memory. Data is lost when the instance is dropped.
This is useful for:
- Testing
- Temporary data
- Performance-critical scenarios where persistence isn’t needed
§Thread Safety
MemoryStorage is thread-safe and can be shared across threads using Arc<MemoryStorage>.
§Example
use gun::storage::{Storage, MemoryStorage};
use gun::state::Node;
use std::sync::Arc;
let storage = Arc::new(MemoryStorage::new());
let node = Node::with_soul("user_123".to_string());
storage.put("user_123", &node).await?;Implementations§
Source§impl MemoryStorage
impl MemoryStorage
Trait Implementations§
Source§impl Default for MemoryStorage
impl Default for MemoryStorage
Source§impl Storage for MemoryStorage
impl Storage for MemoryStorage
Source§fn get<'life0, 'life1, 'async_trait>(
&'life0 self,
soul: &'life1 str,
) -> Pin<Box<dyn Future<Output = GunResult<Option<Node>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn get<'life0, 'life1, 'async_trait>(
&'life0 self,
soul: &'life1 str,
) -> Pin<Box<dyn Future<Output = GunResult<Option<Node>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Retrieve a node by its soul (unique identifier) Read more
Source§fn put<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
soul: &'life1 str,
node: &'life2 Node,
) -> Pin<Box<dyn Future<Output = GunResult<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn put<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
soul: &'life1 str,
node: &'life2 Node,
) -> Pin<Box<dyn Future<Output = GunResult<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Store a node by its soul (unique identifier) Read more
Auto Trait Implementations§
impl !Freeze for MemoryStorage
impl !RefUnwindSafe for MemoryStorage
impl Send for MemoryStorage
impl Sync for MemoryStorage
impl Unpin for MemoryStorage
impl UnwindSafe for MemoryStorage
Blanket Implementations§
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more