Skip to main content

serialize

Function serialize 

Source
pub fn serialize(doc: &DxDocument) -> String
Expand description

Serialize a DxDocument to the LLM text format.

This is the recommended format for most use cases as it’s:

  • Human-readable
  • LLM-friendly (token-efficient)
  • Easy to debug

§Example

use serializer::{serialize, DxDocument, DxLlmValue};

let mut doc = DxDocument::new();
doc.context.insert("name".to_string(), DxLlmValue::Str("MyApp".to_string()));

let text = serialize(&doc);
assert!(text.contains("name") && text.contains("MyApp"));

§Errors

This function is infallible and always returns a valid string representation of the document. The serialization process handles all value types gracefully.