diff --git a/src/formats/serde.rs b/src/formats/serde.rs index da73200..489841c 100644 --- a/src/formats/serde.rs +++ b/src/formats/serde.rs @@ -1,8 +1,8 @@ use serde::{Serialize, Serializer}; -/* use std::collections::HashMap; -use std::hash::BuildHasher; -use zvariant::OwnedValue; */ +use zvariant::OwnedValue; +//use std::hash::BuildHasher; +use serde::ser::SerializeMap; pub fn serialize_actions(actions: &[String], serializer: S) -> Result where @@ -20,6 +20,27 @@ where map.serialize(serializer) } +/* +pub fn serialize_hints(hints: &HashMap, serializer: S) -> Result +where + S: serde::Serializer, +{ + let mut map = serializer.serialize_map(Some(hints.len()))?; + + for (key, value) in hints { + // Try to cast the value to a string, otherwise fallback to debug format + let value_str = match value.downcast_ref::() { + Ok(s) => s.clone(), // Successfully cast to String + Err(_) => format!("{:?}", value), // Fallback for non-String values + }; + + map.serialize_entry(key, &value_str)?; + } + + map.end() +} +*/ + /* pub fn serialize_hints( hints: &HashMap, @@ -38,4 +59,5 @@ where map.serialize(serializer) } -*/ + +*/ \ No newline at end of file diff --git a/src/notification.rs b/src/notification.rs index 538faa6..d278c31 100644 --- a/src/notification.rs +++ b/src/notification.rs @@ -1,4 +1,4 @@ -use crate::formats::serde::serialize_actions; +use crate::formats::serde::serialize_actions;//,serialize_hints}; use serde::Serialize; use std::collections::HashMap; use zbus::{message::Body, Result};