clippy and comments
This commit is contained in:
parent
ac2dc744d5
commit
8e2d189a4d
@ -4,6 +4,8 @@ use std::collections::HashMap;
|
|||||||
use zvariant::OwnedValue;
|
use zvariant::OwnedValue;
|
||||||
|
|
||||||
/// Serialize actions
|
/// Serialize actions
|
||||||
|
/// # Errors
|
||||||
|
/// Will return an empty map if there are no actions
|
||||||
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
|
||||||
S: Serializer,
|
S: Serializer,
|
||||||
@ -21,6 +23,8 @@ where
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Serialize hints
|
/// Serialize hints
|
||||||
|
/// # Errors
|
||||||
|
/// Will return an empty map if there are no hints
|
||||||
pub fn serialize_hints<S>(
|
pub fn serialize_hints<S>(
|
||||||
hints: &HashMap<String, OwnedValue>,
|
hints: &HashMap<String, OwnedValue>,
|
||||||
serializer: S,
|
serializer: S,
|
||||||
@ -45,35 +49,34 @@ impl Serialize for HintValueSerializer<'_> {
|
|||||||
where
|
where
|
||||||
S: Serializer,
|
S: Serializer,
|
||||||
{
|
{
|
||||||
let signature = self.0.value_signature().to_string(); // Signature
|
let signature = self.0.value_signature().to_string(); // Get signature
|
||||||
|
|
||||||
// Extract the raw value correctly
|
// Extract the raw value correctly
|
||||||
let raw_value = if let Ok(v) = self.0.downcast_ref::<u8>() { // BYTE: y
|
let raw_value = if let Ok(v) = self.0.downcast_ref::<u8>() {
|
||||||
Value::from(v)
|
Value::from(v) // BYTE: y
|
||||||
} else if let Ok(v) = self.0.downcast_ref::<bool>() { // BOOLEAN: b
|
} else if let Ok(v) = self.0.downcast_ref::<bool>() {
|
||||||
Value::Bool(v)
|
Value::Bool(v) // BOOLEAN: b
|
||||||
} else if let Ok(v) = self.0.downcast_ref::<i16>() { // INT16: n
|
} else if let Ok(v) = self.0.downcast_ref::<i16>() {
|
||||||
Value::from(v)
|
Value::from(v) // INT16: n
|
||||||
} else if let Ok(v) = self.0.downcast_ref::<u16>() { // UINT16: q
|
} else if let Ok(v) = self.0.downcast_ref::<u16>() {
|
||||||
Value::from(v)
|
Value::from(v) // UINT16: q
|
||||||
} else if let Ok(v) = self.0.downcast_ref::<i32>() { // INT32: i
|
} else if let Ok(v) = self.0.downcast_ref::<i32>() {
|
||||||
Value::from(v)
|
Value::from(v) // INT32: i
|
||||||
} else if let Ok(v) = self.0.downcast_ref::<u32>() { // UINT32: u
|
} else if let Ok(v) = self.0.downcast_ref::<u32>() {
|
||||||
Value::from(v)
|
Value::from(v) // UINT32: u
|
||||||
} else if let Ok(v) = self.0.downcast_ref::<i64>() { // INT64: x
|
} else if let Ok(v) = self.0.downcast_ref::<i64>() {
|
||||||
Value::from(v)
|
Value::from(v) // INT64: x
|
||||||
} else if let Ok(v) = self.0.downcast_ref::<u64>() { // UINT64: t
|
} else if let Ok(v) = self.0.downcast_ref::<u64>() {
|
||||||
Value::from(v)
|
Value::from(v) // UINT64: t
|
||||||
} else if let Ok(v) = self.0.downcast_ref::<f64>() { // DOUBLE: d
|
} else if let Ok(v) = self.0.downcast_ref::<f64>() {
|
||||||
Value::from(v)
|
Value::from(v) // DOUBLE: d
|
||||||
} else if let Ok(v) = self.0.downcast_ref::<String>() { // STRING: s
|
} else if let Ok(v) = self.0.downcast_ref::<String>() {
|
||||||
Value::String(v.clone())
|
Value::String(v.clone()) // STRING: s
|
||||||
} else if let Ok(v) = self.0.downcast_ref::<&str>() { // str
|
} else if let Ok(v) = self.0.downcast_ref::<&str>() {
|
||||||
Value::String(v.to_string())
|
Value::String(v.to_string()) // str
|
||||||
} else { // Unsupported types
|
} else {
|
||||||
Value::Null // Fallback to Null
|
Value::Null // Unsupported types: fallback to Null
|
||||||
// Not implemented: UNIX_FD: h, OBJECT_PATH: o, SIGNATURE: g
|
}; // Not implemented: UNIX_FD: h, OBJECT_PATH: o, SIGNATURE: g
|
||||||
};
|
|
||||||
|
|
||||||
// Serialize the final structure as a map
|
// Serialize the final structure as a map
|
||||||
let mut map = serializer.serialize_map(Some(2))?;
|
let mut map = serializer.serialize_map(Some(2))?;
|
||||||
|
Loading…
Reference in New Issue
Block a user