Português · Full reference by crate
This page explains how ConstructCraft’s code is organized and where its main types live. The full reference lists, crate by crate and module by module, every item that is not private: functions, structs, enums, traits, type aliases, constants and re-exports, with their signatures and documentation, the fields of structs, the variants of enums, the methods of each type and the traits each type implements. It is generated from the source code by cargo run -p api_doc (tools/api_doc), so it always says what the doc comments say; to change it, edit the comments and run the generator again.
If you want to use ConstructCraft from outside (scripts, the command line, AI agents), the command reference and the automation guide are what you need: commands are the stable interface. This reference is for people working on the code itself.
ConstructCraft is written in Rust, which has no classes and no inheritance. The same ideas are expressed with other building blocks, and the reference is organized around them:
| Object-oriented idea | In Rust | In this reference |
|---|---|---|
| Class with fields | struct |
struct, with its Fields |
| Class hierarchy with a closed set of subclasses | enum whose variants carry data |
enum, with its Variants |
| Methods | functions in impl Type { … } blocks, which may live in any module of the crate |
Methods of the type; (in module) says where a method is defined when it is not the type’s own module |
| Interface / abstract base class | trait |
trait, with its Required and provided items and Implemented by |
| Inheriting an interface | a supertrait: trait Command: DeserializeOwned + JsonSchema |
the trait’s signature |
| Implementing an interface | impl Trait for Type |
Traits of the type |
| Generated standard behaviour | #[derive(Clone, Debug, Serialize, …)] |
also listed under Traits |
| Static members | associated functions (no self) and associated constants |
under Methods |
Two patterns stand in for inheritance throughout the code:
Element struct (id, uid, level, type, phases, design option, properties) whose kind: ElementKind holds what kind of element it is: ElementKind::Wall(Wall), Floor(Floor), Door(Hosted), Pipe(MepSegment), Truss(Truss) and so on. Code that would call a virtual method matches on the variant. Types (ElementType with TypeData), views (View with ViewKind) and many smaller things follow the same pattern.Command (cc_engine): every engine command is a struct of parameters implementing it (several hundred implementors).Extension (cc_engine): adds commands to a session; implemented by the plugin host.MemberHost (cc_core): an element that generates structural members (steel buildings, trusses, bracing, wall framing).The code is a Cargo workspace of crates, each a library (or a program) with a single responsibility. Each crate uses only those listed before it in this order, so cc_core depends on no other crate and nothing depends on cc_app:
| Crate | Uses (workspace crates) |
|---|---|
cc_core |
— |
cc_skp |
— |
cc_script |
cc_core |
cc_cad |
cc_core |
cc_geom |
cc_core, cc_script |
cc_views, cc_ifc, cc_render |
cc_core, cc_geom |
cc_raytracing |
cc_core, cc_geom, cc_views |
cc_engine |
cc_core, cc_cad, cc_geom, cc_ifc, cc_raytracing, cc_script, cc_skp, cc_views |
cc_plugins |
cc_engine, cc_script, cc_skp |
cc_cli |
cc_core, cc_engine, cc_plugins |
cc_app |
cc_core, cc_engine, cc_geom, cc_ifc, cc_plugins, cc_raytracing, cc_render, cc_script, cc_views |
What each crate holds:
| Crate | What it holds | Main types |
|---|---|---|
cc_core |
The BIM model, the single source of truth: project, levels, materials, types, elements, views, undo/redo, files. Knows nothing of geometry or UI. | Project, Element, ElementKind, ElementType, TypeData, View, ViewKind, Document, EditCtx, Transaction, ComponentDef, Sketch, ScheduleDef |
cc_geom |
Geometry derived from the model, rebuilt when it changes: wall joins, solids, roofs, rooms, structure, reinforcement, MEP networks, terrain. | ModelGeometry, WallGeom, Solid |
cc_views |
Views as queries over the model: plans, elevations, sections, schedules, sheets, annotations; export to SVG, PDF, PNG and DXF. | generate, Drawing2D, Resolver |
cc_render |
The 3D view’s GPU renderer (wgpu). | Renderer3D |
cc_raytracing |
Photorealistic rendering on the CPU (path tracing). | RenderScene |
cc_ifc |
IFC export and import, with its own STEP reader and writer. | |
cc_cad |
Reading DXF, DWG and SVG drawings into the model’s neutral drawing. | CadDrawing (in cc_core) |
cc_skp |
Reading and writing SketchUp files, with no external dependencies. | SkpFile |
cc_script |
The sandboxed Lua 5.4 used by scripted components and plugins. | |
cc_engine |
The engine: a session and the catalog of commands every client calls; visual programming graphs; localization. | Session, Command, EngineError, Graph, Evaluator |
cc_plugins |
Lua scripts and plugins over the engine. | PluginHost |
cc_cli |
The ccad program: commands, scripts and the MCP server, without a GUI. |
|
cc_app |
The desktop application (egui). | AppState, UiCommand, Tool |
ccad, the MCP server, a Lua script or a graph) asks the Session to run a command by name with JSON parameters, or a typed command struct.run (the Command trait) resolves its references (levels, types and views by id or name) and edits the model through commands::edit, which calls Document::try_edit.EditCtx changes the Project; when it finishes, EditCtx::finish keeps derived data in step (dimensions, attachments, piles, shafts, member hosts, phases, design options, view templates…) and the result passes the repair check. A command that would leave the model invalid is refused without an undo step; otherwise the change is recorded as one reversible Transaction.ModelGeometry::build (cc_geom) rebuilds the geometry and cc_views::generate redraws the views that are shown, each as a Drawing2D; the 3D view goes to Renderer3D.[x, y] in plan, unless a doc comment says otherwise (sizes on paper are millimeters).Result or Option instead of panicking; the engine’s errors are EngineError { code, message }.pub(crate) are internal to their crate; they are listed because the reference is for people working on the code.#[cfg(test)]) is left out.