Skip to main content

plughost_core/
capabilities.rs

1/// Evidence from a native query, not a guarantee that an operation will succeed.
2#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]
3#[non_exhaustive]
4pub enum Support {
5    /// The format has no safe query, or the query did not determine support.
6    #[default]
7    Unknown,
8    /// The native query explicitly reported that the feature is unavailable.
9    Unsupported,
10    /// The native query reported support for the current configuration.
11    Supported,
12}
13
14impl From<bool> for Support {
15    fn from(supported: bool) -> Self {
16        if supported {
17            Self::Supported
18        } else {
19            Self::Unsupported
20        }
21    }
22}
23
24/// A snapshot for the current platform and plugin configuration. Static scan metadata does not
25/// establish these capabilities. Unknown is distinct from explicitly unsupported.
26#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]
27#[non_exhaustive]
28pub struct Capabilities {
29    /// A native editor embedded in the helper's parent window (not a floating-only editor).
30    pub embedded_editor: Support,
31    /// Enumerating detailed audio bus descriptions, not arbitrary layout acceptance.
32    pub bus_discovery: Support,
33    /// Note on/off input and output; does not imply support for all MIDI messages or dialects.
34    pub note_input: Support,
35    /// Producing note on/off events; other event kinds require their own port capabilities.
36    pub note_output: Support,
37    /// Applying normalized parameter edits at sample offsets within a block.
38    pub sample_accurate_automation: Support,
39    /// Saving and restoring native plugin state.
40    pub state: Support,
41    /// Enumerating factory programs/presets. File-based preset loading is a separate operation.
42    pub factory_presets: Support,
43    /// Processing all exposed audio ports in this precision. Layout negotiation may still fail.
44    pub f32: Support,
45    /// Processing all exposed audio ports in double precision; layout negotiation can still fail.
46    pub f64: Support,
47}
48
49/// Native plugin evidence and the isolated Chain API's implementation for the queried slot.
50/// A feature needs both sides to support it. This does not describe the in-process API's limits.
51#[derive(Clone, Copy, Debug, PartialEq, Eq)]
52#[non_exhaustive]
53pub struct CapabilityReport {
54    /// Features reported by the native plugin.
55    pub plugin: Capabilities,
56    /// Features implemented by the isolated host path.
57    pub host: Capabilities,
58}
59
60impl CapabilityReport {
61    /// Combines independent plugin evidence and host implementation support.
62    #[must_use]
63    pub fn new(plugin: Capabilities, host: Capabilities) -> CapabilityReport {
64        CapabilityReport { plugin, host }
65    }
66}