Struct IdMap

Source
pub struct IdMap { /* private fields */ }
Expand description

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

Backed by the filesystem.

Implementations§

Source§

impl IdMap

Source

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

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.

Source§

impl IdMap

Source

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

Find name by a specified integer id.

Source

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

Find VertexName by a specified integer id.

Source

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

Find the integer id matching the given name.

Source

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

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

Source

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

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

Errors if the new entry conflicts with existing entries.

Trait Implementations§

Source§

impl Debug for IdMap

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl IdConvert for IdMap

Source§

fn vertex_id<'life0, 'async_trait>( &'life0 self, name: VertexName, ) -> Pin<Box<dyn Future<Output = Result<Id>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Source§

fn vertex_id_with_max_group<'life0, 'life1, 'async_trait>( &'life0 self, name: &'life1 VertexName, max_group: Group, ) -> Pin<Box<dyn Future<Output = Result<Option<Id>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Source§

fn vertex_name<'life0, 'async_trait>( &'life0 self, id: Id, ) -> Pin<Box<dyn Future<Output = Result<VertexName>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Source§

fn contains_vertex_name<'life0, 'life1, 'async_trait>( &'life0 self, name: &'life1 VertexName, ) -> Pin<Box<dyn Future<Output = Result<bool>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Source§

fn contains_vertex_id_locally<'life0, 'life1, 'async_trait>( &'life0 self, ids: &'life1 [Id], ) -> Pin<Box<dyn Future<Output = Result<Vec<bool>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Test if an id is present locally. Do not trigger remote fetching.
Source§

fn contains_vertex_name_locally<'life0, 'life1, 'async_trait>( &'life0 self, names: &'life1 [VertexName], ) -> Pin<Box<dyn Future<Output = Result<Vec<bool>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Test if an name is present locally. Do not trigger remote fetching.
Source§

fn map_id(&self) -> &str

Identity of the map.
Source§

fn map_version(&self) -> &VerLink

Version of the map. Useful to figure out compatibility between two maps.
Source§

fn vertex_id_optional<'life0, 'life1, 'async_trait>( &'life0 self, name: &'life1 VertexName, ) -> Pin<Box<dyn Future<Output = Result<Option<Id>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Source§

fn vertex_name_batch<'life0, 'life1, 'async_trait>( &'life0 self, ids: &'life1 [Id], ) -> Pin<Box<dyn Future<Output = Result<Vec<Result<VertexName>>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Convert Ids to VertexNames in batch.
Source§

fn vertex_id_batch<'life0, 'life1, 'async_trait>( &'life0 self, names: &'life1 [VertexName], ) -> Pin<Box<dyn Future<Output = Result<Vec<Result<Id>>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Convert VertexNames to Ids in batch.
Source§

impl IdMapWrite for IdMap

Source§

fn insert<'life0, 'life1, 'async_trait>( &'life0 mut self, id: Id, name: &'life1 [u8], ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Insert a new (id, name) pair to the map. Read more
Source§

fn remove_range<'life0, 'async_trait>( &'life0 mut self, low: Id, high: Id, ) -> Pin<Box<dyn Future<Output = Result<Vec<VertexName>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Remove ids in the range low..=high and their associated names. Return removed names.
Source§

impl Persist for IdMap

Source§

type Lock = File

Return type of lock().
Source§

fn lock(&mut self) -> Result<Self::Lock>

Obtain an exclusive lock for writing. This should prevent other writers.
Source§

fn reload(&mut self, _lock: &Self::Lock) -> Result<()>

Reload from the source of truth. Drop pending changes. Read more
Source§

fn persist(&mut self, _lock: &Self::Lock) -> Result<()>

Write pending changes to the source of truth. Read more
Source§

impl PrefixLookup for IdMap

Source§

fn vertexes_by_hex_prefix<'life0, 'life1, 'async_trait>( &'life0 self, hex_prefix: &'life1 [u8], limit: usize, ) -> Pin<Box<dyn Future<Output = Result<Vec<VertexName>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Lookup vertexes by hex prefix.
Source§

impl TryClone for IdMap

Source§

fn try_clone(&self) -> Result<Self>

Auto Trait Implementations§

§

impl Freeze for IdMap

§

impl !RefUnwindSafe for IdMap

§

impl Send for IdMap

§

impl Sync for IdMap

§

impl Unpin for IdMap

§

impl !UnwindSafe for IdMap

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> IdMapAssignHead for T
where T: IdConvert + IdMapWrite,

Source§

fn assign_head<'life0, 'life1, 'life2, 'life3, 'async_trait>( &'life0 mut self, head: VertexName, parents_by_name: &'life1 dyn Parents, group: Group, covered_ids: &'life2 mut IdSet, reserved_ids: &'life3 IdSet, ) -> Pin<Box<dyn Future<Output = Result<PreparedFlatSegments>> + Send + 'async_trait>>
where Self: Send + 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, 'life3: 'async_trait,

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

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

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
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

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

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

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

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more