Expand description
§dotloom-document
The Dotloom document model: stable IDs, namespaced entity types with versions, typed properties, transforms, layers, groups, anchor/parameter references and constraint descriptions, plus structural validation, canonical hashing, copy/paste remapping and schema migration.
This crate is pure data and validation; it has no solver, DOM or GPU dependency.
use dotloom_document::{Document, Entity, EntityId, LayerId, builtin::builtin_type_for};
use dotloom_geometry::{Point, Segment, Shape, ShapeKind};
let mut doc = Document::new();
let id = EntityId(doc.alloc_id());
doc.insert_entity(
Entity::new(id, builtin_type_for(ShapeKind::Line), LayerId(1))
.with_geometry(Shape::Line(Segment::new(Point::new(0.0, 0.0), Point::new(100.0, 0.0)))),
);
assert!(doc.validate().is_ok());
let json = doc.to_json_string().unwrap();
let (back, _) = Document::from_json_str(&json, &Default::default()).unwrap();
assert!(back.semantic_eq(&doc));Modules§
- builtin
- Built-in entity types and their geometry parameters.
Structs§
- Anchor
Ref - A named anchor of an entity:
{"entity": 12, "anchor": "start"}. - Clipboard
- Copied content, independent of the source document.
- Color
- RGBA color, serialized as
#rrggbbor#rrggbbaa. - Constraint
- A stored constraint.
- Constraint
Id - Constraint identifier.
- Dependents
- What references an entity.
- Document
- A Dotloom document: the single editable source of truth (owned by the engine).
- Entity
- A document entity.
- Entity
Id - Entity identifier. Stable for the lifetime of the entity; never reused within
a document (allocated from
Document::next_id). - Grid
Settings - Grid settings (presentation defaults stored with the document).
- Group
- A group of entities and nested groups. Each entity and group has at most one parent group; nesting is acyclic.
- GroupId
- Group identifier.
- Layer
- A layer.
- LayerId
- Layer identifier.
- Limits
- Size limits applied by validation (and by the
.dotlreader). - LineRef
- A line defined by two anchors (segment endpoints, polyline vertices, wall ends…).
- Meta
- Document metadata.
- Migration
Note - A note produced while migrating.
- Param
Ref - Reference to a numeric parameter:
{"entity": 3, "prop": "width"}or{"entity": 3, "geom": "radius"}. - Paste
Report - Result of a paste.
- RefValue
- Reference to another entity:
{"ref": 12}. - Settings
- Document settings.
- Style
- Visual style of an entity. Unset fields inherit from the layer, then the theme.
- Term
- One linear term
coef · param. - TypeId
- Namespaced entity type identifier such as
dotloom.lineoracme.wall.
Enums§
- Cmp
- Comparison operator for linear and expression rules.
- DocError
- Document-level errors (invariant violations, invalid edits, limits).
- Param
Slot - Which slot of an entity a numeric parameter lives in.
- Prop
Value - A typed property value. Numbers are stored in canonical units (mm, rad, s); the dimension of each property comes from its type definition.
- Rule
Spec - Constraint kinds.
- Strength
Spec - Strength as stored in documents.
Constants§
- MAX_
JSON_ DEPTH - Maximum JSON nesting depth accepted for documents.
- OLDEST_
SUPPORTED_ SCHEMA - Oldest schema version that can be migrated.
- SCHEMA_
VERSION - Current document schema version.
Functions§
- fnv1a64
- FNV-1a 64-bit hash.
- migrate
- Migrate a raw document to
SCHEMA_VERSION. - schema_
of - Schema version of a raw document.