Struct PropertiesBox

Source
pub struct PropertiesBox { /* private fields */ }
Expand description

Smart pointer to hold an owned Properties struct.

§Examples

Create a PropertiesBox struct and access the stored values by key:

use pipewire::{properties::{properties, PropertiesBox}};

let props = properties!{
    "Key" => "Value",
    "OtherKey" => "OtherValue"
};

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

Implementations§

Source§

impl PropertiesBox

Source

pub fn new() -> Self

Create a new, initially empty Properties struct.

Source

pub unsafe fn from_raw(ptr: NonNull<pw_properties>) -> Self

Take ownership of an existing raw pw_properties pointer.

§Safety
  • The provided pointer must point to a valid, well-aligned pw_properties struct.
  • After this call, the returned PropertiesBox struct will assume ownership of the data pointed to, so that data must not be freed elsewhere.
Source

pub fn into_raw(self) -> *mut pw_properties

Give up ownership of the contained properties , returning a pointer to the raw pw_properties struct.

After this function, the caller is responsible for pw_properties struct, and should make sure it is freed when it is no longer needed.

Source

pub fn from_dict(dict: &DictRef) -> Self

Create a new Properties from a given dictionary.

All the keys and values from dict are copied.

Methods from Deref<Target = Properties>§

Source

pub fn as_raw(&self) -> &pw_properties

Source

pub fn as_raw_ptr(&self) -> *mut pw_properties

Obtain a pointer to the underlying pw_properties struct.

The pointer is only valid for the lifetime of the Properties struct the pointer was obtained from, and must not be dereferenced after it is dropped.

Ownership of the pw_properties struct is not transferred to the caller and must not be manually freed.

Source

pub fn dict(&self) -> &DictRef

Source

pub fn to_owned(&self) -> PropertiesBox

Source

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

Source

pub fn insert<K, V>(&mut self, key: K, value: V)
where K: Into<Vec<u8>>, V: Into<Vec<u8>>,

Source

pub fn remove<T>(&mut self, key: T)
where T: Into<Vec<u8>>,

Source

pub fn clear(&mut self)

Trait Implementations§

Source§

impl AsRef<DictRef> for PropertiesBox

Source§

fn as_ref(&self) -> &DictRef

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl AsRef<Properties> for PropertiesBox

Source§

fn as_ref(&self) -> &Properties

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl Clone for PropertiesBox

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for PropertiesBox

Source§

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

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

impl Default for PropertiesBox

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl Deref for PropertiesBox

Source§

type Target = Properties

The resulting type after dereferencing.
Source§

fn deref(&self) -> &Self::Target

Dereferences the value.
Source§

impl DerefMut for PropertiesBox

Source§

fn deref_mut(&mut self) -> &mut Self::Target

Mutably dereferences the value.
Source§

impl Drop for PropertiesBox

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

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

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

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

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

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

Source§

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

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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 T
where 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<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

Source§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

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 T
where U: Into<T>,

Source§

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 T
where U: TryFrom<T>,

Source§

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.