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§
Trait Implementations§
Source§impl Default for InMemoryObjectStore
impl Default for InMemoryObjectStore
Source§impl ObjectStore for InMemoryObjectStore
impl ObjectStore for InMemoryObjectStore
Source§fn put(&self, key: &str, data: Vec<u8>) -> Result<(), Error>
fn put(&self, key: &str, data: Vec<u8>) -> Result<(), Error>
Write
data at key. Overwrites any existing object unconditionally.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