Skip to main content

SnapshotSlot

Struct SnapshotSlot 

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

Shared handle to the published custom-state bytes. Held by the shell (producer, audio thread) and the format wrapper (consumer, host / GUI thread), both cloned from one Arc.

Implementations§

Source§

impl SnapshotSlot

Source

pub fn new() -> Arc<Self>

A fresh slot with its publish buffer pre-warmed to SNAPSHOT_PREALLOC. Nothing is published yet, so Self::read returns None until the first Self::publish.

Source

pub fn publish(&self, write: impl FnOnce(&mut Vec<u8>) -> bool)

Audio thread: publish the current snapshot. The buffer is cleared before write runs (its capacity is retained, so a steady state stays allocation-free), so write just fills it and returns whether a snapshot exists - matching the PluginLogic::snapshot_into contract, where a writer that only extends must not accumulate across blocks. Never blocks - on lock contention with a reader the publish is skipped and the previous snapshot stands.

Source

pub fn is_supported(&self) -> bool

Whether the plugin has ever published a snapshot. Cheap atomic read (no lock). Once true it stays true: a plugin’s decision to publish snapshots is a static capability, latched on the first successful publish.

Source

pub fn read(&self) -> Option<Vec<u8>>

Host / GUI thread: the latest published snapshot, or None when the plugin doesn’t publish snapshots (nothing ever written) so the caller can fall back to the locked save_state() path.

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