ifc_lite_core/
lib.rs

1// This Source Code Form is subject to the terms of the Mozilla Public
2// License, v. 2.0. If a copy of the MPL was not distributed with this
3// file, You can obtain one at https://mozilla.org/MPL/2.0/.
4
5//! # IFC-Lite Core Parser
6//!
7//! High-performance STEP/IFC parser built with [nom](https://docs.rs/nom).
8//! Provides zero-copy tokenization and fast entity scanning for IFC files.
9//!
10//! ## Overview
11//!
12//! This crate provides the core parsing functionality for IFC-Lite:
13//!
14//! - **STEP Tokenization**: Zero-copy parsing of STEP file format
15//! - **Entity Scanning**: SIMD-accelerated entity discovery using [memchr](https://docs.rs/memchr)
16//! - **Lazy Decoding**: On-demand attribute parsing for memory efficiency
17//! - **Streaming Parser**: Event-based parsing for large files
18//!
19//! ## Quick Start
20//!
21//! ```rust,ignore
22//! use ifc_lite_core::{EntityScanner, parse_entity, IfcType};
23//!
24//! // Scan for entities
25//! let content = r#"#1=IFCPROJECT('guid',$,$,$,$,$,$,$,$);"#;
26//! let mut scanner = EntityScanner::new(content);
27//!
28//! while let Some((id, type_name, start, end)) = scanner.next_entity() {
29//!     println!("Found entity #{}: {}", id, type_name);
30//! }
31//!
32//! // Parse individual entity
33//! let input = "#123=IFCWALL('guid',$,$,$,$,$,$,$);";
34//! let (id, ifc_type, attrs) = parse_entity(input).unwrap();
35//! assert_eq!(ifc_type, IfcType::IfcWall);
36//! ```
37//!
38//! ## Streaming Parser
39//!
40//! For large files, use the streaming parser to process entities in batches:
41//!
42//! ```rust,ignore
43//! use ifc_lite_core::{parse_stream, StreamConfig, ParseEvent};
44//!
45//! let config = StreamConfig::default();
46//! for event in parse_stream(content, config) {
47//!     match event {
48//!         ParseEvent::Entity { id, type_name, .. } => {
49//!             println!("Entity #{}: {}", id, type_name);
50//!         }
51//!         ParseEvent::Progress { percent, .. } => {
52//!             println!("Progress: {:.1}%", percent);
53//!         }
54//!         _ => {}
55//!     }
56//! }
57//! ```
58//!
59//! ## Performance
60//!
61//! - **Tokenization**: ~1,259 MB/s throughput
62//! - **Entity scanning**: ~650 MB/s with SIMD acceleration
63//! - **Number parsing**: 10x faster than std using [lexical-core](https://docs.rs/lexical-core)
64//!
65//! ## Feature Flags
66//!
67//! - `serde`: Enable serialization support for parsed data
68
69pub mod parser;
70pub mod schema;
71pub mod error;
72pub mod streaming;
73pub mod decoder;
74pub mod schema_gen;
75pub mod georef;
76pub mod fast_parse;
77pub mod generated;
78
79pub use error::{Error, Result};
80pub use parser::{Token, EntityScanner, parse_entity};
81pub use schema::{IfcType, has_geometry_by_name};
82pub use streaming::{ParseEvent, StreamConfig, parse_stream};
83pub use decoder::{EntityDecoder, EntityIndex, build_entity_index};
84pub use schema_gen::{AttributeValue, DecodedEntity, IfcSchema, GeometryCategory, ProfileCategory};
85pub use georef::{GeoReference, GeoRefExtractor, RtcOffset};
86pub use fast_parse::{
87    parse_coordinates_direct, parse_indices_direct, should_use_fast_path,
88    extract_entity_type_name, extract_first_entity_ref, extract_entity_refs_from_list,
89    extract_face_indices_from_entity, extract_coordinate_list_from_entity,
90    process_triangulated_faceset_direct, FastMeshData
91};