pub struct Memory { /* private fields */ }Expand description
The memory façade over the store.
Implementations§
Source§impl Memory
impl Memory
pub fn new(max_value_bytes: usize, list_default_limit: usize) -> Memory
Sourcepub fn check_key(key: &str) -> Result<(), String>
pub fn check_key(key: &str) -> Result<(), String>
Validate a key: non-empty, no whitespace, not reserved, bounded.
Sourcepub fn set(
&mut self,
d: &Durable,
key: &str,
value: Value,
ttl_ms: Option<u64>,
by: Option<&str>,
) -> Result<Value, String>
pub fn set( &mut self, d: &Durable, key: &str, value: Value, ttl_ms: Option<u64>, by: Option<&str>, ) -> Result<Value, String>
memory.set {key, value, ttl?} → the record’s meta.
Sourcepub fn push(
&mut self,
d: &Durable,
key: &str,
value: Value,
by: Option<&str>,
) -> Result<Value, String>
pub fn push( &mut self, d: &Durable, key: &str, value: Value, by: Option<&str>, ) -> Result<Value, String>
memory.push {key, value} — append to the ARRAY at key, creating it.
The durable queue primitive: producers push, a consumer shifts, and the
list survives restarts. Read-modify-write is atomic here because the
reactor is the single writer.
Sourcepub fn shift(
&mut self,
d: &Durable,
key: &str,
by: Option<&str>,
) -> Result<Value, String>
pub fn shift( &mut self, d: &Durable, key: &str, by: Option<&str>, ) -> Result<Value, String>
memory.shift {key} — remove and return the FIRST element
({found: false} on empty or absent — never an error, so a drain loop
can just stop).
Sourcepub fn pop(
&mut self,
d: &Durable,
key: &str,
by: Option<&str>,
) -> Result<Value, String>
pub fn pop( &mut self, d: &Durable, key: &str, by: Option<&str>, ) -> Result<Value, String>
memory.pop {key} — remove and return the LAST element.
Auto Trait Implementations§
impl Freeze for Memory
impl RefUnwindSafe for Memory
impl Send for Memory
impl Sync for Memory
impl Unpin for Memory
impl UnsafeUnpin for Memory
impl UnwindSafe for Memory
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