pub struct ReadOnlyConnection { /* private fields */ }Expand description
Read-only database connection
This connection type enforces read-only access at the API level. All write methods (put, delete, etc.) are not available on this type.
§Use Case
Use this when you need concurrent read access while another process is writing to the database (e.g., Flowtrace App reading while a background script writes).
§Example
ⓘ
use sochdb::ReadOnlyConnection;
// Open read-only connection (acquires shared lock)
let reader = ReadOnlyConnection::open("./data")?;
// Read operations work
let value = reader.get(b"key")?;
let items = reader.scan(b"prefix")?;
// Write operations are not available - compile error!
// reader.put(b"key", b"value"); // Error: no method named `put`Implementations§
Source§impl ReadOnlyConnection
impl ReadOnlyConnection
Sourcepub fn open(path: impl AsRef<Path>) -> Result<Self>
pub fn open(path: impl AsRef<Path>) -> Result<Self>
Open a read-only connection to the database.
Multiple read-only connections can be open simultaneously. Write operations are not available on this connection type.
Sourcepub fn begin_read_txn(&self) -> Result<u64>
pub fn begin_read_txn(&self) -> Result<u64>
Begin a read transaction for consistent snapshot reads
Sourcepub fn end_read_txn(&self) -> Result<()>
pub fn end_read_txn(&self) -> Result<()>
End the read transaction
Sourcepub fn resolve(&self, path: &str) -> Result<PathResolution>
pub fn resolve(&self, path: &str) -> Result<PathResolution>
Resolve a path (O(|path|) lookup)
Sourcepub fn queries_executed(&self) -> u64
pub fn queries_executed(&self) -> u64
Get query statistics
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for ReadOnlyConnection
impl !RefUnwindSafe for ReadOnlyConnection
impl Send for ReadOnlyConnection
impl Sync for ReadOnlyConnection
impl Unpin for ReadOnlyConnection
impl !UnwindSafe for ReadOnlyConnection
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
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>
Converts
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>
Converts
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