pub struct Shmap { /* private fields */ }Implementations§
Source§impl Shmap
impl Shmap
Sourcepub fn new_with_encryption(encryption_key: &[u8; 32]) -> Self
pub fn new_with_encryption(encryption_key: &[u8; 32]) -> Self
Initialize Shmap with AES256 encryption key (random bytes).
Sourcepub fn get<T>(&self, key: &str) -> Result<Option<T>, ShmapError>where
T: DeserializeOwned,
pub fn get<T>(&self, key: &str) -> Result<Option<T>, ShmapError>where
T: DeserializeOwned,
Get an item value by its key, and deserialize it (using bincode) to T.
Sourcepub fn get_raw(&self, key: &str) -> Result<Option<Vec<u8>>, ShmapError>
pub fn get_raw(&self, key: &str) -> Result<Option<Vec<u8>>, ShmapError>
Get an item by its key, without deserialization, as bytes.
Sourcepub fn insert<T>(&self, key: &str, value: T) -> Result<(), ShmapError>where
T: Serialize,
pub fn insert<T>(&self, key: &str, value: T) -> Result<(), ShmapError>where
T: Serialize,
Insert a new item, using bincode serialization.
Sourcepub fn insert_with_ttl<T>(
&self,
key: &str,
value: T,
ttl: Duration,
) -> Result<(), ShmapError>where
T: Serialize,
pub fn insert_with_ttl<T>(
&self,
key: &str,
value: T,
ttl: Duration,
) -> Result<(), ShmapError>where
T: Serialize,
Insert a new item, using bincode serialization, with a TTL.
Sourcepub fn insert_raw_with_ttl(
&self,
key: &str,
value: &[u8],
ttl: Duration,
) -> Result<(), ShmapError>
pub fn insert_raw_with_ttl( &self, key: &str, value: &[u8], ttl: Duration, ) -> Result<(), ShmapError>
Insert a new item, without serialization, with a TTL.
Sourcepub fn insert_raw(&self, key: &str, value: &[u8]) -> Result<(), ShmapError>
pub fn insert_raw(&self, key: &str, value: &[u8]) -> Result<(), ShmapError>
Insert a new item, without serialization.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Shmap
impl RefUnwindSafe for Shmap
impl Send for Shmap
impl Sync for Shmap
impl Unpin for Shmap
impl UnwindSafe for Shmap
Blanket Implementations§
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