Agent-First Data for Rust
# for tracing integration:
use ;
use json;
Useful names use Rust casing: output_json, output_yaml, output_plain, output_json_with_options, redacted_value, redact_secrets_in_place, redact_url_secrets, parse_size, normalize_utc_offset, cli_parse_output, cli_output, build_cli_error, build_cli_version, and cli_handle_version_or_continue.
Tracing integration is behind the tracing feature: afdata_tracing::try_init_json, try_init_plain, and try_init_yaml return initialization errors; the older init_* helpers remain for fire-and-forget setup. CLI help rendering is behind cli-help; skill administration is behind skill-admin.
use ;
use EnvFilter;
Behavior Notes
- Default redaction replaces every
_secretor configured secret-name subtree with***, including objects and arrays. _urlfields scrub userinfo passwords and secret-named query parameters; surrounding whitespace is trimmed and internal whitespace redacts the whole field.- YAML/plain quote and escape keys as well as values, sort by UTF-16 code unit order, and render nested objects in arrays as canonical JSON.
- Logging records use
code: "log"plus a separatelevelfield, so error-level logs are not terminal protocol errors. - Prefer
try_init_*for Rust tracing startup so failures, such as another global subscriber already being installed, are visible to the caller. build_cli_error(message, hint?)returns{code:"error", error: message, hint?}only.- Use
cli_handle_version_or_continue()before clap parsing so--version --output json|yaml|plainstays structured; useVersionConfig::conventional_default()so bare--versionstays human text while explicit--outputremains structured.
Reference
- Full convention and API groups: ../docs/overview.md
- Formal cross-language contract: ../spec/agent-first-data.md
- Conformance fixtures: ../spec/fixtures
- Agent skill: ../skills/agent-first-data.md