Skip to main content

ClosureBridge

Struct ClosureBridge 

Source
pub struct ClosureBridge {
    pub begin_edit: Box<dyn Fn(u32) + Send + Sync>,
    pub set_param: Box<dyn Fn(u32, f64) + Send + Sync>,
    pub end_edit: Box<dyn Fn(u32) + Send + Sync>,
    pub request_resize: Box<dyn Fn(u32, u32) -> bool + Send + Sync>,
    pub get_param: Box<dyn Fn(u32) -> f64 + Send + Sync>,
    pub get_param_plain: Box<dyn Fn(u32) -> f64 + Send + Sync>,
    pub format_param: Box<dyn Fn(u32) -> String + Send + Sync>,
    pub get_meter: Box<dyn Fn(u32) -> f32 + Send + Sync>,
    pub get_state: Box<dyn Fn() -> Vec<u8> + Send + Sync>,
    pub set_state: Box<dyn Fn(Vec<u8>) + Send + Sync>,
    pub transport: Box<dyn Fn() -> Option<TransportInfo> + Send + Sync>,
}
Expand description

Adapter that implements EditorBridge over per-method closures.

Format wrappers that prefer to compose state inline via closures construct one of these and wrap it in an Arc<dyn EditorBridge>. Wrappers that already have a typed host-pointer struct should impl EditorBridge for that struct directly and skip this adapter; one less layer of indirection per call.

Fields§

§begin_edit: Box<dyn Fn(u32) + Send + Sync>§set_param: Box<dyn Fn(u32, f64) + Send + Sync>§end_edit: Box<dyn Fn(u32) + Send + Sync>§request_resize: Box<dyn Fn(u32, u32) -> bool + Send + Sync>§get_param: Box<dyn Fn(u32) -> f64 + Send + Sync>§get_param_plain: Box<dyn Fn(u32) -> f64 + Send + Sync>§format_param: Box<dyn Fn(u32) -> String + Send + Sync>§get_meter: Box<dyn Fn(u32) -> f32 + Send + Sync>§get_state: Box<dyn Fn() -> Vec<u8> + Send + Sync>§set_state: Box<dyn Fn(Vec<u8>) + Send + Sync>§transport: Box<dyn Fn() -> Option<TransportInfo> + Send + Sync>

Trait Implementations§

Source§

impl EditorBridge for ClosureBridge

Source§

fn begin_edit(&self, id: u32)

Start an automation gesture for id. Hosts that show “touched” state in the automation lane use this to render the in-progress edit.
Source§

fn set_param(&self, id: u32, normalized: f64)

Set parameter id to normalized (clamped to 0.0..=1.0). Format wrappers usually plumb this through both the plugin’s own param store and the host’s automation channel.
Source§

fn end_edit(&self, id: u32)

End the automation gesture started by Self::begin_edit.
Source§

fn request_resize(&self, w: u32, h: u32) -> bool

Ask the host to resize the editor window to (w, h) logical points. Returns true if the host accepted the request.
Source§

fn get_param(&self, id: u32) -> f64

Read the parameter’s current normalized value from the plugin (host→GUI sync path).
Source§

fn get_param_plain(&self, id: u32) -> f64

Read the parameter’s current plain (denormalized) value.
Source§

fn format_param(&self, id: u32) -> String

Format the parameter’s current value as a display string, applying the plugin’s format_value impl + unit suffix.
Source§

fn get_meter(&self, id: u32) -> f32

Read a meter value (0.0–1.0) by meter ID. Returns 0.0 if the meter ID isn’t registered.
Source§

fn get_state(&self) -> Vec<u8>

Read the plugin’s custom state (everything outside the parameter system). Returns an empty Vec when the plugin has no custom state.
Source§

fn set_state(&self, data: Vec<u8>)

Write custom state back to the plugin (calls load_state()).
Source§

fn transport(&self) -> Option<TransportInfo>

Most-recently-reported host transport state, or None if the host does not expose transport to plugin editors or the plugin has not yet received a process block. Read more
Source§

fn format_param_into(&self, id: u32, out: &mut String)

Format into a caller-provided buffer instead of returning a fresh String. The default impl calls Self::format_param and copies, so the bridge-internal allocation still happens; the win for the caller is that the out buffer’s capacity is reused across calls (e.g. ParamCache::sync polls one label per changed param per frame and would otherwise drop+reallocate the cached String slot every time). Bridges that produce the formatted string from raw value bytes can override to drop the internal allocation too.

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.