pub struct InMemoryObjectStore { /* private fields */ }Expand description
In-memory object store for tests and local development.
Thread-safe; all ops hold a Mutex for the minimum duration. put_if holds
the lock across the read+write so the compare-and-swap is genuinely atomic,
matching R2’s server-side conditional-write semantics.
Implementations§
Source§impl InMemoryObjectStore
impl InMemoryObjectStore
pub fn new() -> Self
Sourcepub fn contains_key(&self, key: &str) -> bool
pub fn contains_key(&self, key: &str) -> bool
Returns true when key exists (test helper — synchronous, no Result).
Sourcepub fn cache_control(&self, key: &str) -> Option<String>
pub fn cache_control(&self, key: &str) -> Option<String>
Cache-Control the last write to key carried, or None if it was
written through plain ObjectStore::put (test helper).
Trait Implementations§
Source§impl Default for InMemoryObjectStore
impl Default for InMemoryObjectStore
Source§impl ObjectStore for InMemoryObjectStore
impl ObjectStore for InMemoryObjectStore
Source§fn get(&self, key: &str) -> Result<Option<Vec<u8>>, Error>
fn get(&self, key: &str) -> Result<Option<Vec<u8>>, Error>
Read bytes at
key. Returns None when the key does not exist —
NotFound is reserved for ambiguous cases (HEAD-then-GET race etc.).Source§fn delete(&self, key: &str) -> Result<(), Error>
fn delete(&self, key: &str) -> Result<(), Error>
Remove
key. Idempotent — succeeds whether or not the key existed.Source§fn list_prefix(&self, prefix: &str) -> Result<Vec<String>, Error>
fn list_prefix(&self, prefix: &str) -> Result<Vec<String>, Error>
List all keys with the given prefix (prefix-match, not glob).
Auto Trait Implementations§
impl !Freeze for InMemoryObjectStore
impl RefUnwindSafe for InMemoryObjectStore
impl Send for InMemoryObjectStore
impl Sync for InMemoryObjectStore
impl Unpin for InMemoryObjectStore
impl UnsafeUnpin for InMemoryObjectStore
impl UnwindSafe for InMemoryObjectStore
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