Skip to main content

Rust API Map

Use generated assist targets and the generated crate's AGENTS.md before writing Rust queries. Generated entity and request files explicitly direct agents to the assist target; do not guess methods or treat another model's API as transferable.

cargo teaql --input modeling/MODEL.xml rust-assist-query/demo_sys

Replace demo_sys with the generated entity identifier listed by the current workspace instructions.

NeedPrimary APIWhere to inspectApplication use
Start a typed queryGenerated Q facadeAssist output and generated q.rsYes; preferred entry point.
Filter, select, order, paginate, or enhanceGenerated <Entity>RequestAssist output; request source only when needed for diagnosisYes; use emitted methods.
Make a query executableGenerated purpose(...)PurposedQuery<T>Generated request and q.rsYes; use commentpurpose → execution.
Execute a typed readexecute_for_list, execute_for_one, execute_for_first, execute_for_page, execute_for_existsPurposedQuery<<Entity>Request> implementationYes.
Execute records/count/streamexecute_for_records, execute_for_record, execute_for_count, execute_for_streamSame purposed-query implementationYes when the generated method is present.
Read or change fieldsGenerated accessors and update_xxx(...) methodsAssist output and generated entity APIYes; exact names are generated.
Persist a graphaudit_as(...) plus AuditedSave::save(...)Generated request support and entity implementationYes; audit intent is mandatory.
Construct the runtimeservice_runtime_from_env, service_runtime, service_runtime_from_poolGenerated runtime.rsSupported application entry points.
Supply repositoriesTeaqlRepositoryProvider and generated repository accessorsGenerated request_support.rsSupported integration boundary.
Configure audit/schemateaql_tool_core::audit_config_from_env(...)Generated runtime.rs and environment referenceStartup integration boundary.
Replace data-service behaviorteaql-data-service executor traits and provider extensionsRuntime/provider cratesAdvanced infrastructure boundary.
Edit generated entity/request/runtime filesGenerated crate internalsGenerated outputNo; change the model or generator and regenerate.

Query Shape

let users = Q::user_info()
.with_name_containing("Ada")
.comment("Filter users by display name")
.purpose("Render the user directory")
.execute_for_list(&ctx)
.await?;

The concrete facade, filter, selection, and terminal methods vary with the model and generator. In the verified generated workspace, terminal methods are implemented only on PurposedQuery<<Entity>Request>, so an unpurposed request does not expose them.

Mutation Shape

use demo_service_core::AuditedSave as _;

user.update_name("Ada Lovelace");
user.audit_as("Correct the user's display name")
.save(&ctx)
.await?;

Inspect assist output for the exact update method and required trait import. Do not call the generated entity's internal save path directly.

Generated, Runtime, and Handwritten Boundaries

  • Generated: Q, entities, requests, expressions, checkers, repository-provider traits, runtime assembly, and sample data. Regenerate instead of editing.
  • Runtime: entity graph, request/value model, data-service traits, provider implementations, audit configuration, and context resources.
  • Handwritten: application orchestration, behaviors outside generated files, provider selection/configuration, and tests using public generated APIs.

The verified Rust Golden Path generated both rust-lib-core and rust-app-console, compiled and tested them, started SQLite, executed an intent-declared query and audited mutation, then regenerated after a model change. The generated sample_data.rs still contains two query calls without comment; that is a generator-template defect, not a pattern to copy.