Skip to main content

Module serialization

Module serialization 

Source
Expand description

Serialization module for converting external data formats to string values.

These functions convert data from external formats (JSON, MsgPack, Protobuf) into string values ready for use with ExecutionPlan::with_values().

  • null values are skipped (treated as “fact not provided”)
  • JSON numbers, booleans, arrays, objects are converted to their string representation

§Example

use lemma::serialization::from_json;

let json = br#"{"discount": 21, "config": {"key": "value"}, "name": null}"#;
let values = from_json(json, &execution_plan)?;
// discount -> "21"
// config -> "{\"key\":\"value\"}"
// name -> skipped (null)
let plan = execution_plan.with_values(values, &limits)?;

Functions§

deserialize_fact_doc_ref_map
Custom deserializer for HashMap<FactPath, String> (document references)
deserialize_fact_path_map
Custom deserializer for HashMap<FactPath, LemmaFact>
deserialize_fact_path_set
Custom deserializer for HashSet
deserialize_fact_source_map
Custom deserializer for HashMap<FactPath, Source> (fact sources)
deserialize_fact_type_map
Custom deserializer for HashMap<FactPath, LemmaType>
deserialize_fact_value_map
Custom deserializer for HashMap<FactPath, LiteralValue>
from_json
Parse JSON to string values for use with ExecutionPlan::with_values().
from_msgpack
Convert MsgPack values to string values for use with ExecutionPlan::with_values().
from_protobuf
Convert Protobuf values to string values for use with ExecutionPlan::with_values().
serialize_fact_doc_ref_map
Custom serializer for HashMap<FactPath, String> (document references)
serialize_fact_path_map
Custom serializer for HashMap<FactPath, LemmaFact>
serialize_fact_path_set
Custom serializer for HashSet
serialize_fact_source_map
Custom serializer for HashMap<FactPath, Source> (fact sources)
serialize_fact_type_map
Custom serializer for HashMap<FactPath, LemmaType>
serialize_fact_value_map
Custom serializer for HashMap<FactPath, LiteralValue>