Struct libpulse_binding::proplist::Proplist
source · pub struct Proplist { /* private fields */ }
Expand description
A property list object. Basically a dictionary with ASCII strings as keys and arbitrary data as values.
Implementations
sourceimpl Proplist
impl Proplist
sourcepub fn new_from_string(s: &str) -> Option<Self>
pub fn new_from_string(s: &str) -> Option<Self>
Allocate a new property list and assign key/value from a human readable string.
sourcepub fn key_is_valid(key: &str) -> bool
pub fn key_is_valid(key: &str) -> bool
Returns true
if the key is valid.
sourcepub fn sets(&mut self, key: &str, value: &str) -> Result<(), ()>
pub fn sets(&mut self, key: &str, value: &str) -> Result<(), ()>
Append a new string entry to the property list, possibly overwriting an already existing entry with the same key. An internal copy is made of the provided string.
sourcepub fn setp(&mut self, pair: &str) -> Result<(), ()>
pub fn setp(&mut self, pair: &str) -> Result<(), ()>
Append a new string entry to the property list, possibly overwriting an already existing entry with the same key.
This is similar to sets
, however here the provided key and value are
combined into a single string, separated by an =
. An internal copy is made of the provided
string.
sourcepub fn set(&mut self, key: &str, data: &[u8]) -> Result<(), ()>
pub fn set(&mut self, key: &str, data: &[u8]) -> Result<(), ()>
Append a new arbitrary data entry to the property list, possibly overwriting an already existing entry with the same key. An internal copy of the provided data is made.
sourcepub fn gets(&self, key: &str) -> Option<String>
pub fn gets(&self, key: &str) -> Option<String>
Return a string entry for the specified key. Will return None
if the key does not exist or
if data is not valid UTF-8.
sourcepub fn get(&self, key: &str) -> Option<&[u8]>
pub fn get(&self, key: &str) -> Option<&[u8]>
Get the value for the specified key.
For string entries, the value store will be NUL-terminated. The caller should make a copy of the data before the property list is accessed again.
Returns a slice formed from the data pointer and the length of the data.
Returns None
if key does not exist.
sourcepub fn merge(&mut self, other: &Self, mode: UpdateMode)
pub fn merge(&mut self, other: &Self, mode: UpdateMode)
Merge property list “other” into self, adhering to the merge mode specified.
sourcepub fn unset(&mut self, key: &str) -> Result<(), PAErr>
pub fn unset(&mut self, key: &str) -> Result<(), PAErr>
Removes a single entry from the property list, identified by the specified key name.
sourcepub fn unset_many(&mut self, keys: &[&str]) -> Option<u32>
pub fn unset_many(&mut self, keys: &[&str]) -> Option<u32>
Similar to unset
but takes an array of keys to remove.
Returns None
on failure, otherwise the number of entries actually removed (which might
even be 0, if there were no matching entries to remove).
sourcepub fn iter(&self) -> Iterator ⓘ
pub fn iter(&self) -> Iterator ⓘ
Get an immutable iterator over the list’s keys.
The property list should not be modified during iteration through the list, with the exception of deleting the current entry. The keys in the property list do not have any particular order.
for key in my_props.iter() {
//do something with it
println!("key: {}", key);
}
sourcepub fn to_string(&self) -> Option<String>
pub fn to_string(&self) -> Option<String>
Format the property list nicely as a human readable string.
This works very much like to_string_sep
and uses a newline as
separator and appends one final one.
sourcepub fn to_string_sep(&self, sep: &str) -> Option<String>
pub fn to_string_sep(&self, sep: &str) -> Option<String>
Format the property list nicely as a human readable string, choosing the separator used.