Skip to main content

Crate dotloom_document

Crate dotloom_document 

Source
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§

AnchorRef
A named anchor of an entity: {"entity": 12, "anchor": "start"}.
Clipboard
Copied content, independent of the source document.
Color
RGBA color, serialized as #rrggbb or #rrggbbaa.
Constraint
A stored constraint.
ConstraintId
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.
EntityId
Entity identifier. Stable for the lifetime of the entity; never reused within a document (allocated from Document::next_id).
GridSettings
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 .dotl reader).
LineRef
A line defined by two anchors (segment endpoints, polyline vertices, wall ends…).
Meta
Document metadata.
MigrationNote
A note produced while migrating.
ParamRef
Reference to a numeric parameter: {"entity": 3, "prop": "width"} or {"entity": 3, "geom": "radius"}.
PasteReport
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.line or acme.wall.

Enums§

Cmp
Comparison operator for linear and expression rules.
DocError
Document-level errors (invariant violations, invalid edits, limits).
ParamSlot
Which slot of an entity a numeric parameter lives in.
PropValue
A typed property value. Numbers are stored in canonical units (mm, rad, s); the dimension of each property comes from its type definition.
RuleSpec
Constraint kinds.
StrengthSpec
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.