Which API do I use

Decision tables for picking the right constructor, resolution method, value representation and editor API in dxn_dtcg.

The crate has one entry point, DtcgRuntime, and a handful of methods that differ in how much they resolve and what they return. Find your task in the tables below.

#Creating the runtime

You haveUse
One token document, or one resolver with inline sources, as a stringDtcgRuntime::from_json(id, json)
A resolver that references other filesDtcgRuntime::default() then set_root(id), and load on demand
All documents up front (embedded assets, tests)from_json for the root, then provide_json_batch([...])
Custom limits, or the value extensionsthe *_with_options variants or DtcgRuntime::with_options(options)
Tokens computed by expressionsthe expressions feature, then RuntimeOptions::default().with_expressions(ExpressionOptions::default()) passed to those constructors

Options are fixed at construction. default() and from_json use default limits and strict DTCG 2025.10 values.

#Getting tokens out

You wantUseReturns
Every token for a selectionruntime.resolve(&selection)Resolution<ResolvedTokens>
A struct of just the tokens you needruntime.project::<T>(&selection)Resolution<T>
Several structs from one selectionresolve once, then T::project(&tokens, runtime.registry()) per structResult<T, DtcgError>
One token as typed Rust datatokens.get(path)?.typed(&runtime.options().extensions)TypedValue
A nested plain DTCG document of the final valuestokens.to_document()serde_json::Value

#Representing values

You needUse
Raw JSON, to feed another libraryResolvedToken::value
A Rust model per DTCG type (Color, Dimension, Shadow, …)dxn_dtcg::values types as struct fields, or ResolvedToken::typed
Your own type (a renderer’s color, std::time::Duration)impl FromDtcgValue for YourType when you own the type, else #[dtcg(with = "convert_fn")] on the field
The value as authored, aliases intact (to show or preserve them)ResolvedToken::authored_value
The authored $value of a token whose expression was evaluatedResolvedToken::snapshot
A color in another space, mixed, lightened, as hex, or its contrastthe values::Color methods (Color conversions)

#Selections and pickers

You wantUse
The modifiers and contexts to build a theme pickerruntime.modifiers() (root resolver only)
A validated, complete selection with defaults filled in, usable as a cache keyruntime.normalize_selection(&selection)
A selection from a settings file or URL as JSONselection_from_json(&json) then selection_refs(&owned)

#Loading and checking

You wantUse
Load only what one selection needsloop on resolve until Ready
Load the JavaScript or TypeScript modules expressions importthe same loop; answer DocumentKind::Module requests with provide_requested_module (module documents)
Fetch every context’s documents (offline cache, bundle)loop on validate_complete()
Check that every theme combination resolves (CI)resolve every combination of modifiers(); see the cookbook
Validate one value without a runtimevalidate_value(type, &value) or validate_value_with

#Editors and tools

You wantUse
Re-resolve after an edit, touching only affected tokensreplace_json_and_resolve_affected, then ResolvedTokens::apply_affected
Preview an unsaved source on top of the catalogpreview_source (or preview_occurrence for one occurrence)
Check a draft set or modifier before saving itvalidate_source
See the authored sources, their origins, dormant and shadowed onesinspect_source
Find every $ref between files (move a file safely)source_references()
Detect “nothing changed” cheaplycompare ResolvedTokens::fingerprint()

#Pitfalls

Next: Cookbook for worked recipes, or API reference.