attempt - hint serialize
This commit is contained in:
parent
21002f6521
commit
58aed0897d
@ -20,6 +20,24 @@ where
|
||||
map.serialize(serializer)
|
||||
}
|
||||
|
||||
pub fn serialize_hints<S>(hints: &HashMap<String, OwnedValue>, serializer: Serializer) -> Result<S::Ok, S::Error>
|
||||
{
|
||||
let mut hint_map = serde_json::Map::new();
|
||||
|
||||
for hint in hints {
|
||||
if 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()));
|
||||
}
|
||||
}
|
||||
|
||||
hint_map.serialize(serializer)
|
||||
}
|
||||
|
||||
/*
|
||||
pub fn serialize_hints<S>(hints: &HashMap<String, OwnedValue>, serializer: S) -> Result<S::Ok, S::Error>
|
||||
where
|
||||
|
@ -1,4 +1,4 @@
|
||||
use crate::formats::serde::serialize_actions; //,serialize_hints};
|
||||
use crate::formats::serde::{serialize_actions,serialize_hints};
|
||||
use serde::Serialize;
|
||||
use std::collections::HashMap;
|
||||
use zbus::{message::Body, Result};
|
||||
@ -21,7 +21,7 @@ pub struct Notification {
|
||||
#[serde(serialize_with = "serialize_actions")]
|
||||
actions: Vec<String>,
|
||||
// Useful extra data - notif type, urgency, notif sound, icon data, etc.
|
||||
//#[serde(serialize_with = "serialize_hints")]
|
||||
#[serde(serialize_with = "serialize_hints")]
|
||||
hints: HashMap<String, OwnedValue>,
|
||||
// Seconds till this notif expires. Optional
|
||||
expir_timeout: i32,
|
||||
|
Loading…
Reference in New Issue
Block a user