pub struct LockedIndex {
pub index: Index,
/* private fields */
}Expand description
Exclusive handle to the index, backed by an advisory flock on .beans/index.lock.
Prevents concurrent read-modify-write races when multiple agents run in parallel.
The lock is held from acquisition until save_and_release is called or the
LockedIndex is dropped.
use bn::index::LockedIndex;
let mut locked = LockedIndex::acquire(beans_dir)?;
locked.index.beans[0].title = "Updated".to_string();
locked.save_and_release()?;Fields§
§index: IndexImplementations§
Source§impl LockedIndex
impl LockedIndex
Sourcepub fn acquire(beans_dir: &Path) -> Result<Self>
pub fn acquire(beans_dir: &Path) -> Result<Self>
Acquire an exclusive lock on the index, then load or rebuild it. Uses the default 5-second timeout.
Sourcepub fn acquire_with_timeout(beans_dir: &Path, timeout: Duration) -> Result<Self>
pub fn acquire_with_timeout(beans_dir: &Path, timeout: Duration) -> Result<Self>
Acquire an exclusive lock with a custom timeout.
Sourcepub fn save_and_release(self) -> Result<()>
pub fn save_and_release(self) -> Result<()>
Save the modified index and release the lock.
Trait Implementations§
Source§impl Debug for LockedIndex
impl Debug for LockedIndex
Auto Trait Implementations§
impl Freeze for LockedIndex
impl RefUnwindSafe for LockedIndex
impl Send for LockedIndex
impl Sync for LockedIndex
impl Unpin for LockedIndex
impl UnsafeUnpin for LockedIndex
impl UnwindSafe for LockedIndex
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