This commit is contained in:
Candifloss 2024-10-20 23:13:07 +05:30
parent 28c808f07f
commit 2d42401b52

View File

@ -3,6 +3,8 @@ use std::collections::HashMap;
use zvariant::OwnedValue;
//use std::hash::BuildHasher;
use serde::ser::SerializeMap;
use serde_json::{Map,Value};
use zvariant::SerializeValue;
pub fn serialize_actions<S>(actions: &[String], serializer: S) -> Result<S::Ok, S::Error>
where
@ -27,19 +29,12 @@ pub fn serialize_hints<S>(
where
S: Serializer,
{
let mut hint_map = serde_json::Map::new();
for hint in hints {
let (hint_name, hint_val) = hint;
let mut h = serde_json::Map::new();
let sig = hint_val.value_signature();
let val = hint_val.try_clone();
h.insert(sig.to_string(), serde_json::Value::String(val));
hint_map.insert(hint_name.clone(), serde_json::Value::Object(h.clone()));
// You can customize the serialization logic here
let mut state = serializer.serialize_map(Some(hints.len()))?;
for (key, value) in hints {
state.serialize_entry(key, value)?;
}
hint_map.serialize(serializer)
state.end()
}
/*