pub struct NameRegistry { /* private fields */ }Expand description
A two-way RefId <-> String mapping. Every entity a
super::NamedModel exposes — a vertex, edge, face or solid — has
exactly one live entry here for as long as it exists. Its maps share
their structure with their copies, as the topology’s do.
Names are chosen by whoever creates the entity, following the scheme in the crate docs, never generated here from a counter: a counter depends on creation order, which is exactly what a name must not depend on.
Implementations§
Source§impl NameRegistry
impl NameRegistry
pub fn new() -> Self
Sourcepub fn insert(
&mut self,
id: impl Into<RefId>,
name: impl Into<String>,
) -> GeopResult<()>
pub fn insert( &mut self, id: impl Into<RefId>, name: impl Into<String>, ) -> GeopResult<()>
Registers id under name. Fails if id is already registered
(under any name) or if name is already taken by a different id.
Sourcepub fn alias(
&mut self,
name: impl Into<String>,
into: impl Into<String>,
) -> GeopResult<()>
pub fn alias( &mut self, name: impl Into<String>, into: impl Into<String>, ) -> GeopResult<()>
Lets name, the name of an entity made part of the entity named
into — two faces on one surface made one, two edges joined —
stand for into from now on, so what referred to either still
finds it. Fails if name names an entity of its own.
Sourcepub fn aliases_of(&self, name: &str) -> Vec<String>
pub fn aliases_of(&self, name: &str) -> Vec<String>
What else stands for the entity name names (see Self::alias), in
order.
Sourcepub fn rename(
&mut self,
id: impl Into<RefId>,
new_name: impl Into<String>,
) -> GeopResult<()>
pub fn rename( &mut self, id: impl Into<RefId>, new_name: impl Into<String>, ) -> GeopResult<()>
Gives the already named id the name new_name instead.
For an operation that can only tell what an entity should be called once it has finished — a boolean numbers the crossings of two edges along one of them, which it knows only after finding all of them. It names such entities provisionally while it runs and settles every name before it returns; nothing outside the operation ever sees a provisional one.
Sourcepub fn remove(&mut self, id: impl Into<RefId>)
pub fn remove(&mut self, id: impl Into<RefId>)
Forgets id and its name. A no-op if id was never registered.
pub fn name_of(&self, id: impl Into<RefId>) -> Option<&str>
Sourcepub fn is_taken(&self, name: &str) -> bool
pub fn is_taken(&self, name: &str) -> bool
Whether name is an entity’s own name — not merely an alias, which
a new entity may take over.
Trait Implementations§
Source§impl Clone for NameRegistry
impl Clone for NameRegistry
Source§fn clone(&self) -> NameRegistry
fn clone(&self) -> NameRegistry
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more