Skip to main content

dotloom_document/
lib.rs

1//! # dotloom-document
2//!
3//! The Dotloom document model: stable IDs, namespaced entity types with versions,
4//! typed properties, transforms, layers, groups, anchor/parameter references and
5//! constraint descriptions, plus structural validation, canonical hashing,
6//! copy/paste remapping and schema migration.
7//!
8//! This crate is pure data and validation; it has no solver, DOM or GPU dependency.
9//!
10//! ```
11//! use dotloom_document::{Document, Entity, EntityId, LayerId, builtin::builtin_type_for};
12//! use dotloom_geometry::{Point, Segment, Shape, ShapeKind};
13//!
14//! let mut doc = Document::new();
15//! let id = EntityId(doc.alloc_id());
16//! doc.insert_entity(
17//!     Entity::new(id, builtin_type_for(ShapeKind::Line), LayerId(1))
18//!         .with_geometry(Shape::Line(Segment::new(Point::new(0.0, 0.0), Point::new(100.0, 0.0)))),
19//! );
20//! assert!(doc.validate().is_ok());
21//! let json = doc.to_json_string().unwrap();
22//! let (back, _) = Document::from_json_str(&json, &Default::default()).unwrap();
23//! assert!(back.semantic_eq(&doc));
24//! ```
25
26pub mod builtin;
27mod canonical;
28mod clipboard;
29mod constraint;
30mod document;
31mod error;
32mod ids;
33mod migrate;
34mod model;
35mod validate;
36mod value;
37
38pub use canonical::fnv1a64;
39pub use clipboard::{Clipboard, PasteReport};
40pub use constraint::{Cmp, Constraint, LineRef, ParamRef, ParamSlot, RuleSpec, StrengthSpec, Term};
41pub use document::{Dependents, Document};
42pub use error::DocError;
43pub use ids::{ConstraintId, EntityId, GroupId, LayerId, TypeId};
44pub use migrate::{MAX_JSON_DEPTH, MigrationNote, OLDEST_SUPPORTED_SCHEMA, SCHEMA_VERSION, migrate, schema_of};
45pub use model::{Entity, GridSettings, Group, Layer, Meta, Settings};
46pub use validate::Limits;
47pub use value::{AnchorRef, Color, PropValue, RefValue, Style};