Skip to content

Commit

Permalink
refactor: move identifier aliases back to relevant modules
Browse files Browse the repository at this point in the history
  • Loading branch information
imrn99 committed Apr 16, 2024
1 parent c768858 commit b6d752c
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 47 deletions.
32 changes: 31 additions & 1 deletion honeycomb-core/src/cells/collections.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
// ------ IMPORTS

use crate::{CMap2, CoordsFloat, EdgeIdentifier, FaceIdentifier, VertexIdentifier};
use crate::{CMap2, CoordsFloat};

// ------ CONTENT

Expand All @@ -25,6 +25,13 @@ macro_rules! collection_constructor {

// --- vertices

/// Type definition for vertex identifiers
///
/// This is used for better control over memory usage and ID encoding.
pub type VertexIdentifier = u32;

pub const NULL_VERTEX_ID: VertexIdentifier = 0;

pub struct VertexCollection<'a, T: CoordsFloat> {
lifetime_indicator: std::marker::PhantomData<&'a CMap2<T>>,
pub identifiers: Vec<VertexIdentifier>,
Expand All @@ -34,6 +41,13 @@ collection_constructor!(VertexCollection, VertexIdentifier);

// --- edges

/// Type definition for edge identifiers
///
/// This is used for better control over memory usage and ID encoding.
pub type EdgeIdentifier = u32;

pub const NULL_EDGE_ID: EdgeIdentifier = 0;

pub struct EdgeCollection<'a, T: CoordsFloat> {
lifetime_indicator: std::marker::PhantomData<&'a CMap2<T>>,
pub identifiers: Vec<EdgeIdentifier>,
Expand All @@ -43,9 +57,25 @@ collection_constructor!(EdgeCollection, EdgeIdentifier);

// --- faces

/// Type definition for face identifiers
///
/// This is used for better control over memory usage and ID encoding.
pub type FaceIdentifier = u32;

pub const NULL_FACE_ID: FaceIdentifier = 0;

pub struct FaceCollection<'a, T: CoordsFloat> {
lifetime_indicator: std::marker::PhantomData<&'a CMap2<T>>,
pub identifiers: Vec<FaceIdentifier>,
}

collection_constructor!(FaceCollection, FaceIdentifier);

// --- volumes

/// Type definition for volume identifiers
///
/// This is used for better control over memory usage and ID encoding.
pub type VolumeIdentifier = u32;

pub const NULL_VOLUME_ID: VolumeIdentifier = 0;
41 changes: 0 additions & 41 deletions honeycomb-core/src/cells/identifiers.rs

This file was deleted.

10 changes: 9 additions & 1 deletion honeycomb-core/src/cells/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,13 @@
// ------ MODULE DECLARATIONS

pub mod collections;
pub mod identifiers;
pub mod orbits;

// ------ CONTENT

/// Type definition for dart identifiers
///
/// This is used for better control over memory usage and ID encoding.
pub type DartIdentifier = u32;

pub const NULL_DART_ID: DartIdentifier = 0;
9 changes: 5 additions & 4 deletions honeycomb-core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,13 @@ pub use attributes::{
traits::{AttributeBind, AttributeUpdate},
};
pub use cells::{
collections::{EdgeCollection, FaceCollection, VertexCollection},
identifiers::{
DartIdentifier, EdgeIdentifier, FaceIdentifier, VertexIdentifier, VolumeIdentifier,
NULL_DART_ID, NULL_EDGE_ID, NULL_FACE_ID, NULL_VERTEX_ID, NULL_VOLUME_ID,
collections::{
EdgeCollection, EdgeIdentifier, FaceCollection, FaceIdentifier, VertexCollection,
VertexIdentifier, VolumeIdentifier, NULL_EDGE_ID, NULL_FACE_ID, NULL_VERTEX_ID,
NULL_VOLUME_ID,
},
orbits::{Orbit2, OrbitPolicy},
DartIdentifier, NULL_DART_ID,
};
pub use spatial_repr::{
coords::{Coords2, CoordsError},
Expand Down

0 comments on commit b6d752c

Please sign in to comment.