Skip to main content

Crate jsonld_expandable_core

Crate jsonld_expandable_core 

Source
Expand description

Runtime support for the JSON-LD Expandable derive macro.

This crate hosts:

  • The Expandable trait that the derive macro implements.
  • The JsonValue backend trait abstracting any JSON value type the derive can emit (serde_json::Value, sonic_rs::Value, jstrict::Value, or a user-supplied type).
  • The ToJsonValue trait used by generated code to convert leaf field values into a chosen JsonValue backend.
  • Behind the codegen feature: the attribute parser, intermediate representation, and codegen used by the jsonld-expandable proc-macro crate (kept here so they can be unit-tested without trybuild). Only the derive crate enables the feature; runtime consumers never pull in syn/quote/proc-macro2, and those modules are internal API for the derive, not covered by semver.

Application code rarely depends on this crate directly; instead enable an expandable* feature on the umbrella jsonld crate, which re-exports both the derive and this crate (as jsonld::expandable_core). The derive reads the consuming crate’s manifest and points the code it generates at whichever of the two that crate depends on, following a renamed dependency to the name it was given.

§Limitations

The derive does not add trait bounds for generic parameters: a generic struct would need T: ToJsonValue<V>-style bounds on the generated impl, which the derive cannot express yet. Deriving on a generic struct fails with unresolved trait-bound errors; use concrete field types.

Traits§

Expandable
Convert &self into the expanded JSON-LD form for the chosen backend V.
ExpandableLanguageMap
Renders a field tagged #[jsonld(container = "language")].
ExpandableTypeValue
Field marker for dynamic @type arrays.
JsonValue
Minimal vocabulary for any JSON value type the derive can construct.
ToJsonValue
Convert a leaf field value to the chosen JsonValue backend.