pub struct NameRegistry { /* private fields */ }Expand description
A two-way RefId <-> String mapping. Every entity a crate::Part
exposes — a vertex, edge, face, solid or sketch — has exactly one live
entry here for as long as it exists.
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 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.
Sourcepub fn retain(&mut self, alive: impl FnMut(RefId) -> bool)
pub fn retain(&mut self, alive: impl FnMut(RefId) -> bool)
Forgets every entry whose id alive rejects.
pub fn name_of(&self, id: impl Into<RefId>) -> Option<&str>
pub fn id_of(&self, name: &str) -> Option<RefId>
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