Macro pipewire::properties[][src]

macro_rules! properties {
    { $($k : expr => $v : expr), + $(,) ? } => { ... };
}
Expand description

A macro for creating a new Properties struct with predefined key-value pairs.

The macro accepts a list of Key => Value pairs, seperated by commas.

Examples:

Create a Properties struct from literals.

use pipewire::properties;

let props = properties!{
   "Key1" => "Value1",
   "Key2" => "Value2",
};

Any expression that evaluates to a impl Into<Vec<u8>> can be used for both keys and values.

use pipewire::prelude::*;
use pipewire::properties;

let key = String::from("Key");
let value = vec![86, 97, 108, 117, 101]; // "Value" as an ASCII u8 vector.
let props = properties!{
    key => value
};

assert_eq!(Some("Value"), props.get("Key"));