pub struct LmdbStorage { /* private fields */ }Expand description
Content-addressed LMDB storage.
Uses heed (LMDB wrapper) for memory-mapped, transactional chunk storage.
Keys are 32-byte XorName addresses, values are raw chunk bytes.
Implementations§
Source§impl LmdbStorage
impl LmdbStorage
Sourcepub async fn new(config: LmdbStorageConfig) -> Result<Self>
pub async fn new(config: LmdbStorageConfig) -> Result<Self>
Create a new LMDB storage instance.
Opens (or creates) an LMDB environment at {root_dir}/chunks.mdb/.
§Errors
Returns an error if the LMDB environment cannot be opened.
Sourcepub async fn put_raw(&self, address: &XorName, data: &[u8]) -> Result<bool>
pub async fn put_raw(&self, address: &XorName, data: &[u8]) -> Result<bool>
Store data at the given address without content-address verification.
Use this for data types where the address is not BLAKE3(content).
§Errors
Returns an error if the write fails.
Sourcepub async fn put_overwrite(&self, address: &XorName, data: &[u8]) -> Result<()>
pub async fn put_overwrite(&self, address: &XorName, data: &[u8]) -> Result<()>
Overwrite a record at the given address without content-address verification.
Unlike put_raw, this does not check for existing records and will
overwrite them. Used for mutable data types where
the handler has already validated the update.
§Errors
Returns an error if the write fails.
Sourcepub async fn get_raw(&self, address: &XorName) -> Result<Option<Vec<u8>>>
pub async fn get_raw(&self, address: &XorName) -> Result<Option<Vec<u8>>>
Retrieve raw data without content-address verification.
Use this for non-chunk data types where the stored bytes are serialized records, not raw content.
§Errors
Returns an error if the read fails.
Sourcepub fn stats(&self) -> StorageStats
pub fn stats(&self) -> StorageStats
Get storage statistics.
Sourcepub fn current_chunks(&self) -> Result<u64>
pub fn current_chunks(&self) -> Result<u64>
Return the number of chunks currently stored, queried from LMDB metadata.
This is an O(1) read of the B-tree page header — not a full scan.
§Errors
Returns an error if the LMDB read transaction fails.
Sourcepub fn compute_address(content: &[u8]) -> XorName
pub fn compute_address(content: &[u8]) -> XorName
Compute content address (BLAKE3 hash).
Auto Trait Implementations§
impl !Freeze for LmdbStorage
impl !RefUnwindSafe for LmdbStorage
impl Send for LmdbStorage
impl Sync for LmdbStorage
impl Unpin for LmdbStorage
impl UnsafeUnpin for LmdbStorage
impl UnwindSafe for LmdbStorage
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
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more