[][src]Struct esl01_dag::idmap::SyncableIdMap

pub struct SyncableIdMap<'a> { /* fields omitted */ }

Guard to make sure IdMap on-disk writes are race-free.

Constructing this struct will take a filesystem lock and reload the content from the filesystem. Dropping this struct will write down changes to the filesystem and release the lock.

Methods

impl<'a> SyncableIdMap<'a>[src]

pub fn sync(&mut self) -> Result<()>[src]

Write pending changes to disk.

Methods from Deref<Target = IdMap>

pub fn prepare_filesystem_sync(&mut self) -> Result<SyncableIdMap>[src]

Return a SyncableIdMap instance that provides race-free filesytem read and write access by taking an exclusive lock.

The SyncableIdMap instance provides a sync method that actually writes changes to disk.

Block if another instance is taking the lock.

pub fn reload(&mut self) -> Result<()>[src]

Reload from the filesystem. Discard pending changes.

pub fn find_name_by_id(&self, id: Id) -> Result<Option<&[u8]>>[src]

Find name by a specified integer id.

pub fn find_vertex_name_by_id(&self, id: Id) -> Result<Option<VertexName>>[src]

Find VertexName by a specified integer id.

pub fn find_id_by_name(&self, name: &[u8]) -> Result<Option<Id>>[src]

Find the integer id matching the given name.

pub fn find_id_by_name_with_max_group(
    &self,
    name: &[u8],
    max_group: Group
) -> Result<Option<Id>>
[src]

Similar to find_name_by_id, but returns None if group > max_group.

pub fn insert(&mut self, id: Id, name: &[u8]) -> Result<()>[src]

Insert a new entry mapping from a name to an id.

Errors if the new entry conflicts with existing entries.

pub fn next_free_id(&self, group: Group) -> Result<Id>[src]

Return the next unused id in the given group.

pub fn find_names_by_hex_prefix(
    &self,
    hex_prefix: &[u8],
    limit: usize
) -> Result<Vec<Cow<[u8]>>>
[src]

Lookup names by hex prefix.

pub fn assign_head<F>(
    &mut self,
    head: VertexName,
    parents_by_name: F,
    group: Group
) -> Result<Id> where
    F: Fn(VertexName) -> Result<Vec<VertexName>>, 
[src]

Assign an id for a head in a DAG. This implies ancestors of the head will also have ids assigned.

This function is incremental. If the head or any of its ancestors already have an id stored in this map, the existing ids will be reused.

This function needs roughly O(N) heap memory. N is the number of ids to assign. When N is very large, try assigning ids to a known ancestor first.

New ids inserted by this function will have the specified group. Existing ids that are ancestors of head will get re-assigned if they have a higher group.

pub fn build_get_parents_by_id<'a>(
    &'a self,
    get_parents_by_name: &'a dyn Fn(VertexName) -> Result<Vec<VertexName>>
) -> impl Fn(Id) -> Result<Vec<Id>> + 'a
[src]

Translate get_parents from taking names to taking Ids.

pub fn remove_non_master(&mut self) -> Result<()>[src]

Mark non-master ids as "removed".

Trait Implementations

impl<'a> Deref for SyncableIdMap<'a>[src]

type Target = IdMap

The resulting type after dereferencing.

impl<'a> DerefMut for SyncableIdMap<'a>[src]

Auto Trait Implementations

impl<'a> !RefUnwindSafe for SyncableIdMap<'a>

impl<'a> Send for SyncableIdMap<'a>

impl<'a> Sync for SyncableIdMap<'a>

impl<'a> Unpin for SyncableIdMap<'a>

impl<'a> !UnwindSafe for SyncableIdMap<'a>

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<V, T> VZip<V> for T where
    V: MultiLane<T>,