Skip to main content

StoreHandle

Struct StoreHandle 

Source
pub struct StoreHandle<'a> { /* private fields */ }
Expand description

Property storage handle.

This handle can be used to store the properties of a plugin. It uses the atom system to encode the properties and is backed by a storage callback function.

The written properties a buffered and flushed when requested. Create new properties by calling draft and write them like any other atom. Once you are done, you can commit your properties by calling commit_all or commit. You have to commit manually: Uncommitted properties will be discarded when the handle is dropped.

Implementations§

Source§

impl<'a> StoreHandle<'a>

Source

pub fn new(store_fn: LV2_State_Store_Function, handle: LV2_State_Handle) -> Self

Create a new store handle.

Source

pub fn draft<K: ?Sized>( &mut self, property_key: URID<K>, ) -> StatePropertyWriter<'_>

Draft a new property.

This will return a new handle to create a property. Once the property is completely written, you can commit it by calling commit or commit_all. Then, and only then, it will be saved by the host.

If you began to write a property and don’t want the written things to be stored, you can discard it with discard or discard_all.

Source

pub fn commit_pair<K: ?Sized>( store_fn: LV2_State_Store_Function, handle: LV2_State_Handle, key: URID<K>, space: SpaceElement, ) -> Result<(), StateErr>

Internal helper function to store a property.

Source

pub fn commit_all(&mut self) -> Result<(), StateErr>

Commit all created properties.

This will also clear the property buffer.

Source

pub fn commit<K: ?Sized>( &mut self, key: URID<K>, ) -> Option<Result<(), StateErr>>

Commit one specific property.

This method returns None if the requested property was not marked for commit, Some(Ok(())) if the property was stored and Some(Err(_)) if an error occured while storing the property.

Source

pub fn discard_all(&mut self)

Discard all drafted properties.

Source

pub fn discard<K: ?Sized>(&mut self, key: URID<K>)

Discard a drafted property.

If no property with the given key was drafted before, this is a no-op.

Auto Trait Implementations§

§

impl<'a> Freeze for StoreHandle<'a>

§

impl<'a> RefUnwindSafe for StoreHandle<'a>

§

impl<'a> !Send for StoreHandle<'a>

§

impl<'a> !Sync for StoreHandle<'a>

§

impl<'a> Unpin for StoreHandle<'a>

§

impl<'a> UnsafeUnpin for StoreHandle<'a>

§

impl<'a> !UnwindSafe for StoreHandle<'a>

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