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 zvariant::OwnedValue;
//use std::hash::BuildHasher; //use std::hash::BuildHasher;
use serde::ser::SerializeMap; 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> pub fn serialize_actions<S>(actions: &[String], serializer: S) -> Result<S::Ok, S::Error>
where where
@ -27,19 +29,12 @@ pub fn serialize_hints<S>(
where where
S: Serializer, S: Serializer,
{ {
let mut hint_map = serde_json::Map::new(); // You can customize the serialization logic here
let mut state = serializer.serialize_map(Some(hints.len()))?;
for hint in hints { for (key, value) in hints {
let (hint_name, hint_val) = hint; state.serialize_entry(key, value)?;
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()));
} }
state.end()
hint_map.serialize(serializer)
} }
/* /*