Expand description
The operations every adapter calls (ADR R1): the command line, the JSON-lines service
(draftwright serve) and the MCP server (draftwright-mcp) are thin layers over these.
analyse,plan,edit,render(with [write]),specandreview, typed, over the documents ofcrate::model;plan_analysed,render_analysedandreview_analysedtake an Analysis thatanalysemade, so the caller need not re-analyse;analyse_from,plan_from,render_fromandreview_fromtake where the features come from (Features), Rust quiddity’s recognition among them (the command line’s default); the others, andcall, take Python quiddity’s JSON or none;spec_ops: the edit ops that turn one Spec into another;call: the same operations by name with JSON arguments, as the service and the MCP server receive them. Requests carry their documents and name the STEP file by path, so nothing is kept between calls.Serviceadditionally owns the live JSON-lines session.
An Error is invalid (the request cannot be met as asked; it says what would be accepted)
or failed (something went wrong; each file is published only when complete).
Re-exports§
pub use crate::png::DPI;
Structs§
- Error
- Why an operation did not complete.
- Review
- A drawing to look at: the plan rendered as SVG, with its problems and lint’s findings on the drawing.
- Service
Enums§
- Features
- Where an analysis takes the part’s features from.
Constants§
- DEFAULT_
FORMATS - The formats written when none are named: the drawing’s vector files.
- FORMATS
- The formats
renderwrites, including editable DXF drawings. - MONO
- The drawing’s font (IBM Plex Mono), bundled.
- OPERATIONS
- The operations
callanswers, in the order they are usually used. - SESSION_
OPERATIONS - Additional operations on the connection’s one live part; batch operations still work.
- STATELESS_
OPERATIONS - Stateless subprocess operations; tool calls use the same published MCP schemas.
Functions§
- analyse
- The Analysis of the STEP file at step, with the features in features, Python quiddity’s
recognition JSON for the same file (
crate::bridge), when given. - analyse_
from - The Analysis of the STEP file at step, with its features from features.
- analyse_
part analyse_fromof part part of an assembly alone, when given.- call
- Operation op with JSON arguments args, its result as JSON:
- edit
- spec with the edit operations ops applied.
- parts
- The distinct parts of the STEP file at step, in the order a part is chosen by
(
model::analyse_step_part): each one’s index, name, product id, face count and number of placements. - plan
- The Plan for the STEP file at step (with features, as for
analyse) under spec. - plan_
analysed - The Plan for analysis (made by
analyse) under spec. No STEP file is read; a document of a versionmodel::plandoes not read is refused. Every plan here has draftwright’s layout recovery applied (model::plan_recovered). - plan_
from - The Plan for the STEP file at step, with its features from features, under spec.
- plan_
part plan_fromof part part of an assembly alone, when given.- render
- The plan (its problems with the drawing’s), and the drawing in each of formats (from
FORMATS) as bytes, each carrying the spec; a PNG atDPI. - render_
analysed render_atfrom analysis (made byanalysefrom the STEP file at step) in place of analysing it again: refused when analysis is of another version, or was made from another file (its binding’s SHA-256 or face count differs).- render_
at render, with a PNG at dpi pixels per inch: refused, as draftwright refuses it, when a PNG is asked for and dpi is not positive.- render_
from render_at, with the part’s features from features.- render_
part render_fromof part part of an assembly alone, when given.- review
- The drawing of the STEP file at step under spec, as SVG text, with its problems and lint’s findings.
- review_
analysed reviewfrom analysis in place of analysing the STEP file again, refused asrender_analysedrefuses it.- review_
from review, with the part’s features from features.- review_
part review_fromof part part of an assembly alone, when given.- spec
- The spec embedded in the drawing (SVG, DXF, PDF or PNG) at drawing.
- spec_
ops - The
setandremoveops on escaped paths (crate::items::key) that turn Spec before into after, ascrate::items::Ops forcrate::session::Session::apply: object keys in sorted order,schemaat the root skipped, arrays and scalars replaced whole, an object new in after set key by key (an empty one set whole,{}), and a key missing in after removed. An explicitnullin after also removes the key, as the MCP’sspec_diffdoes; the editor’sspecOperationssetsnullthere instead. A serialised Spec never holdsnull, so for Specs the three agree. - write
- Writes each rendered file at out with its format’s extension appended (
part.rev2→part.rev2.svg; an out already ending in a drawing format’s extension has it replaced, as draftwright’s_output_prefixdoes), and returns the paths written. Each is written to a uniquely and exclusively created sibling, then atomically replaces its destination. A failed write/rename does not replace that destination and removes only this invocation’s staged copy (ADR5-10). Concurrent writers use last-writer-wins per file (the last successful rename). A multi-format export is not transactional: formats may come from different writers, and a later failure leaves already published formats in place.
Type Aliases§
- Files
- Rendered files: each suffix (
svg,sheet2.svg,pdf, etc.) and its bytes.