pub enum Trigger {
Momentary,
Continuous,
}Expand description
What kind of input an action expects.
ADR-0012. Declared rather than inferred, because the two are not interchangeable and binding one to the other is always a mistake: a fader bound to “next track” would skip a hundred tracks across one sweep, and a key bound to “set volume” has no position to send.
Variants§
Momentary
A press. The ordinary case, and the default an addon author should reach for.
Continuous
A position — a fader, 0..=16383.
The daemon coalesces these, so an action sees where the fader ended up rather than every point it passed through. An action that needs the whole gesture is a different thing and this is not it.
Implementations§
Source§impl Trigger
impl Trigger
Sourcepub const fn as_wire(self) -> &'static str
pub const fn as_wire(self) -> &'static str
How it is spelled on a wire.
§Why this is a method and not a match at each end
Because it was three matches, and they had to agree without anything
making them. The addon-to-daemon encoder lived in
run, the daemon-to-interface encoder in
nobble_rpc::AddonDto::of, and the decoder between them was
if a.trigger == "continuous" in the daemon — with a TypeScript
=== "continuous" at the far end comparing against the result. Five
hand-written copies of two strings, on a round trip where a single
disagreement makes a fader silently behave like a key: the decoder’s
else branch is Momentary, so a renamed encoding does not fail, it
degrades.
Constitution VI is about exactly that, and the remedy it prefers —
generated bindings — is unavailable inside one language. One definition
on the type is the next thing: nobble-core re-exports this type, so
every crate downstream is looking at the same impl rather than at its
own copy of the answer.
Not a display name. These are protocol tokens, lowercase because that is what is on the wire, and a renaming here is a breaking protocol change rather than a wording change. An interface wanting Momentary with a capital M writes that itself.
Sourcepub fn from_wire(s: &str) -> Option<Self>
pub fn from_wire(s: &str) -> Option<Self>
Read one back, or None if this build has no name for it.
An Option rather than a default, deliberately. The daemon’s decode
used to fall back to Self::Momentary for anything unrecognised,
which turns an addon built against a newer SDK into a fader that behaves
like a key with nothing reported — a Principle IV collapse. Whether to
refuse or to default is the caller’s decision to state out loud; this
only declines to make it for them.