starting to fix hints serialization
This commit is contained in:
parent
f568ac111d
commit
45bf3a87b9
@ -1,8 +1,8 @@
|
|||||||
use serde::{Serialize, Serializer};
|
use serde::{Serialize, Serializer};
|
||||||
/*
|
|
||||||
use std::collections::HashMap;
|
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<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
|
||||||
@ -20,6 +20,27 @@ where
|
|||||||
map.serialize(serializer)
|
map.serialize(serializer)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
pub fn serialize_hints<S>(hints: &HashMap<String, OwnedValue>, serializer: S) -> Result<S::Ok, S::Error>
|
||||||
|
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::<String>() {
|
||||||
|
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<S, H>(
|
pub fn serialize_hints<S, H>(
|
||||||
hints: &HashMap<String, OwnedValue, H>,
|
hints: &HashMap<String, OwnedValue, H>,
|
||||||
@ -38,4 +59,5 @@ where
|
|||||||
|
|
||||||
map.serialize(serializer)
|
map.serialize(serializer)
|
||||||
}
|
}
|
||||||
|
|
||||||
*/
|
*/
|
@ -1,4 +1,4 @@
|
|||||||
use crate::formats::serde::serialize_actions;
|
use crate::formats::serde::serialize_actions;//,serialize_hints};
|
||||||
use serde::Serialize;
|
use serde::Serialize;
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
use zbus::{message::Body, Result};
|
use zbus::{message::Body, Result};
|
||||||
|
Loading…
Reference in New Issue
Block a user