Skip to content

Commit 452ca72

Browse files
committed
support for binary input
1 parent 8e0a425 commit 452ca72

1 file changed

Lines changed: 10 additions & 0 deletions

File tree

src/convert.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,16 @@ pub fn to_message_item(value: &Value, expected_type: Option<&DbusType>)
141141
(Value::String { val, .. }, Some(DbusType::Double)) =>
142142
Ok(MessageItem::Double(try_convert!(f64::from_str(&val[..])))),
143143

144+
// Binary
145+
(Value::Binary { val, .. }, Some(r#type @ DbusType::Array(content_type)))
146+
if matches!(**content_type, DbusType::Byte) =>
147+
{
148+
// FIXME: this is likely pretty inefficient for a bunch of bytes
149+
let sig = Signature::from(r#type.stringify());
150+
let items = val.iter().cloned().map(MessageItem::Byte).collect::<Vec<_>>();
151+
Ok(MessageItem::Array(MessageItemArray::new(items, sig).unwrap()))
152+
},
153+
144154
// List/array
145155
(Value::List { vals, .. }, Some(r#type @ DbusType::Array(content_type))) => {
146156
let sig = Signature::from(r#type.stringify());

0 commit comments

Comments
 (0)