pub struct Proplist(_);
Expand description

A property list object. Basically a dictionary with ASCII strings as keys and arbitrary data as values.

Implementations§

source§

impl Proplist

source

pub fn new() -> Option<Self>

Allocates a property list.

source

pub fn new_from_string(s: &str) -> Option<Self>

Allocates a new property list and assigns key/value from a human readable string.

source

pub fn key_is_valid(key: &str) -> bool

Checks if the key is valid.

source

pub fn set_str(&mut self, key: &str, value: &str) -> Result<(), ()>

Appends 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.

source

pub fn set_pl(&mut self, pair: &str) -> Result<(), ()>

Appends a new string entry to the property list, possibly overwriting an already existing entry with the same key.

This is similar to set_str(), 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.

source

pub fn set(&mut self, key: &str, data: &[u8]) -> Result<(), ()>

Appends 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.

source

pub fn get_str(&self, key: &str) -> Option<String>

Gets a string entry for the specified key.

Will return None if the key does not exist or if data is not valid UTF-8.

source

pub fn get(&self, key: &str) -> Option<&[u8]>

Gets 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 any subsequent modification or destruction of the property list.

Returns a slice formed from the data pointer and the length of the data. Returns None if key does not exist.

source

pub fn merge(&mut self, other: &Self, mode: UpdateMode)

Merges property list “other” into self, adhering to the merge mode specified.

source

pub fn unset(&mut self, key: &str) -> Result<(), PAErr>

Removes a single entry from the property list, identified by the specified key name.

source

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).

source

pub fn iter(&self) -> Iterator<'_>

Gets 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);
}
source

pub fn to_string(&self) -> Option<String>

Formats 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.

source

pub fn to_string_sep(&self, sep: &str) -> Option<String>

Formats the property list nicely as a human readable string, choosing the separator used.

source

pub fn contains(&self, key: &str) -> Option<bool>

Checks if this contains an entry with the given key.

Returns true if an entry for the specified key exists in the property list. Returns None on error.

source

pub fn clear(&mut self)

Removes all entries from the property list object.

source

pub fn len(&self) -> u32

Gets the number of entries in the property list.

source

pub fn is_empty(&self) -> bool

Checks if the proplist is empty.

Trait Implementations§

source§

impl Clone for Proplist

source§

fn clone(&self) -> Self

Allocates a new property list and copy over every single entry from the specified list.

If this is called on a ‘weak’ instance, a non-weak object is returned.

1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for Proplist

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl IntoIterator for Proplist

§

type Item = String

The type of the elements being iterated over.
§

type IntoIter = Iterator<'static>

Which kind of iterator are we turning this into?
source§

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. Read more
source§

impl PartialEq<Proplist> for Proplist

source§

fn eq(&self, other: &Self) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl Send for Proplist

source§

impl Sync for Proplist

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> ToOwned for Twhere T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.