pub fn to_json_ld(
model: &DataModel,
root: Option<&str>,
) -> Result<JsonLdHeader, Box<dyn Error>>Expand description
Generate a full JSON-LD document header for the given data model.
This function constructs a JsonLdHeader for a DataModel, using its prefix,
object name, and any configured context prefixes. It builds the @context, @id,
and @type fields required for compliant JSON-LD output. An explicit root object
can be chosen by its name; otherwise, the first object in the model is used.
§Arguments
model- Reference to the sourceDataModel.root- Optional name of the root object; ifNone, the model’s first object is used.
§Returns
Ok(JsonLdHeader)containing complete JSON-LD metadata for the root object.Err(Box<dyn Error>)if the root cannot be found or context creation fails.
§Example
ⓘ
let header = to_json_ld(&model, Some("EnzymeMLDocument")).unwrap();