[][src]Struct esl01_dag::idmap::IdMap

pub struct IdMap { /* fields omitted */ }

Bi-directional mapping between an integer id and a name ([u8]).

Methods

impl IdMap[src]

pub fn open(path: impl AsRef<Path>) -> Result<Self>[src]

Create an IdMap backed by the given directory.

By default, only read-only operations are allowed. For writing access, call [IdMap::make_writable] to get a writable instance.

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.

impl IdMap[src]

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.

impl IdMap[src]

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

Mark non-master ids as "removed".

Trait Implementations

impl Debug for IdMap[src]

impl IdMapLike for IdMap[src]

Auto Trait Implementations

impl !RefUnwindSafe for IdMap

impl Send for IdMap

impl Sync for IdMap

impl Unpin for IdMap

impl !UnwindSafe for IdMap

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>,