dxf_tools_rs/lib.rs
1//! # DXF-Tools-RS
2//!
3//! A pure Rust library for reading and writing CAD files in DXF format.
4//!
5//! This library provides comprehensive DXF file support with high performance
6//! and memory efficiency, inspired by [ACadSharp](https://github.com/DomCR/ACadSharp).
7//!
8//! ## Features
9//!
10//! - Read and write DXF files (ASCII and Binary formats)
11//! - Support for 30+ entity types
12//! - Complete table system (Layers, LineTypes, Blocks, TextStyles, DimensionStyles)
13//! - Extended data (XData) support
14//! - Multiple DXF versions (R12 through 2018+)
15//!
16//! ## Quick Start
17//!
18//! ```rust,ignore
19//! use dxf_tools_rs::{CadDocument, io::dxf::DxfReader};
20//!
21//! // Read a DXF file
22//! let doc = DxfReader::from_file("sample.dxf")?.read()?;
23//!
24//! // Access entities
25//! for entity in doc.entities() {
26//! println!("Entity: {:?}", entity);
27//! }
28//!
29//! // Write to DXF
30//! use dxf_tools_rs::io::dxf::DxfWriter;
31//! DxfWriter::new(doc).write_to_file("output.dxf")?;
32//! # Ok::<(), dxf_tools_rs::error::DxfError>(())
33//! ```
34//!
35//! ## Architecture
36//!
37//! The library uses a trait-based design for maximum flexibility:
38//!
39//! - `CadObject` - Base trait for all CAD objects
40//! - `Entity` - Trait for graphical entities
41//! - `TableEntry` - Trait for table entries
42//! - `CadDocument` - Central document structure
43//!
44//! ## Performance
45//!
46//! DXF-Tools-RS is designed for high performance:
47//!
48//! - 2-3x faster than the C# version
49//! - 30-50% less memory usage
50//! - Zero-copy parsing where possible
51//! - Parallel processing for large files
52
53#![allow(missing_docs)]
54#![warn(rustdoc::missing_crate_level_docs)]
55
56pub mod entities;
57pub mod error;
58pub mod types;
59pub mod tables;
60pub mod document;
61pub mod io;
62pub mod xdata;
63pub mod objects;
64
65// Re-export commonly used types
66pub use error::{DxfError, Result};
67pub use types::{
68 DxfVersion, BoundingBox2D, BoundingBox3D, Color, Handle, LineWeight, Transparency, Vector2,
69 Vector3,
70};
71
72// Re-export entity types
73pub use entities::{
74 Arc, Circle, Ellipse, Entity, EntityType, Line, LwPolyline, MText, Point, Polyline, Spline,
75 Text,
76};
77
78// Re-export table types
79pub use tables::{
80 AppId, BlockRecord, DimStyle, Layer, LineType, Table, TableEntry, TextStyle, Ucs, VPort, View,
81};
82
83// Re-export document
84pub use document::CadDocument;
85
86// Re-export I/O types
87pub use io::dxf::{DxfReader, DxfWriter};
88
89/// Library version
90pub const VERSION: &str = env!("CARGO_PKG_VERSION");
91
92#[cfg(test)]
93mod tests {
94 use super::*;
95
96 #[test]
97 fn test_version() {
98 assert!(!VERSION.is_empty());
99 }
100
101 #[test]
102 fn test_cad_document_creation() {
103 let doc = CadDocument::new();
104 assert_eq!(doc.version, DxfVersion::AC1032);
105
106 let doc2 = CadDocument::with_version(DxfVersion::AC1015);
107 assert_eq!(doc2.version, DxfVersion::AC1015);
108 }
109}
110