Skip to main content

Message

Enum Message 

Source
pub enum Message {
Show 32 variants Sandboxed { mechanism: String, }, Hello { magic: [u8; 4], major: u16, minor: u16, }, Load { path: String, format: PluginFormat, class_id: Option<[u8; 16]>, }, Configure { rate: u32, max_frames: u32, in_channels: u16, out_channels: u16, }, Editor(EditorAction), EditorStatus(EditorStatus), EditorImage(EditorImage), Prepare(ProcessingSetup), Describe, Features(Capabilities), Activate, SetState { blob: Vec<u8>, }, GetState, OpenEditor { scaling: EditorScaling, }, OpenEditorIn { parent: ParentWindow, scaling: EditorScaling, }, CloseEditor, ListParameters { start: u32, count: u16, }, Parameters { total: u32, entries: Vec<Parameter>, }, SetParameter { id: u32, value: f64, }, RequestError { code: u32, text: String, }, Shutdown, Scan { path: String, }, Loaded { name: String, vendor: String, latency_frames: u32, inputs: Vec<BusInfo>, outputs: Vec<BusInfo>, }, Classes { entries: Vec<ClassInfo>, }, LatencyChanged { frames: u32, }, State { blob: Vec<u8>, }, ParamsChanged, Fault { code: u32, text: String, }, Ack, EditorClosed, EditorResized { width: u32, height: u32, }, ParameterEdit { id: u32, phase: EditPhase, value: f64, },
}

Variants§

§

Sandboxed

Sent before Hello only when an OS sandbox was requested and installed.

Fields

§mechanism: String
§

Hello

Fields

§magic: [u8; 4]
§major: u16
§minor: u16
§

Load

Fields

§path: String
§class_id: Option<[u8; 16]>
§

Configure

Fields

§rate: u32
§max_frames: u32
§in_channels: u16
§out_channels: u16
§

Editor(EditorAction)

§

EditorStatus(EditorStatus)

§

EditorImage(EditorImage)

§

Prepare(ProcessingSetup)

§

Describe

§

Features(Capabilities)

§

Activate

§

SetState

Fields

§blob: Vec<u8>
§

GetState

§

OpenEditor

Fields

§

OpenEditorIn

Fields

§

CloseEditor

§

ListParameters

Fields

§start: u32
§count: u16
§

Parameters

Fields

§total: u32
§entries: Vec<Parameter>
§

SetParameter

Fields

§id: u32
§value: f64
§

RequestError

Fields

§code: u32
§text: String
§

Shutdown

§

Scan

Fields

§path: String
§

Loaded

Fields

§name: String
§vendor: String
§latency_frames: u32
§inputs: Vec<BusInfo>
§outputs: Vec<BusInfo>
§

Classes

Fields

§entries: Vec<ClassInfo>
§

LatencyChanged

Fields

§frames: u32
§

State

Fields

§blob: Vec<u8>
§

ParamsChanged

§

Fault

Fields

§code: u32
§text: String
§

Ack

The reply to a request that returns no data (Configure, Activate, SetState, OpenEditor). It carries the request’s number.

§

EditorClosed

The editor window was closed by the user.

§

EditorResized

Fields

§width: u32
§height: u32
§

ParameterEdit

Fields

§id: u32
§value: f64

Implementations§

Source§

impl Message

Source

pub fn hello() -> Self

Examples found in repository?
examples/control_seeds.rs (line 13)
11fn messages() -> Vec<(&'static str, Message)> {
12    vec![
13        ("hello", Message::hello()),
14        (
15            "load",
16            Message::Load {
17                path: "plugin.vst3".into(),
18                format: PluginFormat::Vst3,
19                class_id: None,
20            },
21        ),
22        (
23            "configure",
24            Message::Configure {
25                rate: 48_000,
26                max_frames: 512,
27                in_channels: 2,
28                out_channels: 2,
29            },
30        ),
31        ("activate", Message::Activate),
32        (
33            "set-state",
34            Message::SetState {
35                blob: b"state".to_vec(),
36            },
37        ),
38        ("get-state", Message::GetState),
39        (
40            "open-editor",
41            Message::OpenEditor {
42                scaling: EditorScaling::Auto,
43            },
44        ),
45        ("shutdown", Message::Shutdown),
46        (
47            "scan",
48            Message::Scan {
49                path: "plugin.vst3".into(),
50            },
51        ),
52        (
53            "loaded",
54            Message::Loaded {
55                name: "plugin".into(),
56                vendor: "vendor".into(),
57                latency_frames: 0,
58                inputs: vec![],
59                outputs: vec![],
60            },
61        ),
62        ("classes", Message::Classes { entries: vec![] }),
63        ("latency-changed", Message::LatencyChanged { frames: 64 }),
64        (
65            "state",
66            Message::State {
67                blob: b"state".to_vec(),
68            },
69        ),
70        ("params-changed", Message::ParamsChanged),
71        (
72            "fault",
73            Message::Fault {
74                code: 1,
75                text: "fault".into(),
76            },
77        ),
78        ("ack", Message::Ack),
79        ("editor-closed", Message::EditorClosed),
80        ("close-editor", Message::CloseEditor),
81        (
82            "list-parameters",
83            Message::ListParameters { start: 0, count: 1 },
84        ),
85        (
86            "parameters",
87            Message::Parameters {
88                total: 0,
89                entries: vec![],
90            },
91        ),
92        ("set-parameter", Message::SetParameter { id: 1, value: 0.5 }),
93        (
94            "request-error",
95            Message::RequestError {
96                code: 1,
97                text: "error".into(),
98            },
99        ),
100        (
101            "prepare",
102            Message::Prepare(ProcessingSetup {
103                sample_rate: 48_000,
104                quantum: 512,
105                sample_format: SampleFormat::F32,
106                offline: false,
107                inputs: vec![],
108                outputs: vec![],
109            }),
110        ),
111        ("describe", Message::Describe),
112        ("features", Message::Features(Capabilities::default())),
113        ("editor", Message::Editor(EditorAction::Show)),
114        (
115            "editor-status",
116            Message::EditorStatus(EditorStatus {
117                platform: EditorPlatform::X11,
118                scaling: EditorScaling::Auto,
119                visible: true,
120                embedded: false,
121                width: 640,
122                height: 480,
123                scale: 1.0,
124                resize_supported: true,
125                scale_supported: true,
126            }),
127        ),
128        (
129            "editor-image",
130            Message::EditorImage(EditorImage {
131                width: 1,
132                height: 1,
133                rgba: vec![32, 64, 128, 255],
134            }),
135        ),
136        (
137            "sandboxed",
138            Message::Sandboxed {
139                mechanism: "test".into(),
140            },
141        ),
142        (
143            "open-editor-in",
144            Message::OpenEditorIn {
145                parent: ParentWindow::X11 { window: 1 },
146                scaling: EditorScaling::Auto,
147            },
148        ),
149        (
150            "editor-resized",
151            Message::EditorResized {
152                width: 640,
153                height: 480,
154            },
155        ),
156        (
157            "parameter-edit",
158            Message::ParameterEdit {
159                id: 1,
160                phase: EditPhase::Perform,
161                value: 0.5,
162            },
163        ),
164    ]
165}
Source

pub fn kind(&self) -> u16

The wire kind number, for diagnostics.

Examples found in repository?
examples/control_seeds.rs (line 187)
167fn verify(directory: &Path) {
168    let mut kinds = Vec::new();
169    for entry in fs::read_dir(directory)
170        .expect("read corpus")
171        .map(Result::unwrap)
172    {
173        let path = entry.path();
174        if path.extension().and_then(|value| value.to_str()) != Some("bin") {
175            continue;
176        }
177        let bytes = fs::read(&path).expect("read seed");
178        let DecodedFrame::Known(frame) = decode_frame(&bytes).expect("seed must decode") else {
179            panic!("{} decoded as Unknown", path.display());
180        };
181        assert_eq!(
182            encode_frame(&frame).expect("re-encode seed"),
183            bytes,
184            "{}",
185            path.display()
186        );
187        kinds.push(frame.message.kind());
188    }
189    kinds.sort_unstable();
190    assert_eq!(kinds, (1_u16..=32).collect::<Vec<_>>());
191    println!(
192        "verified {} Known control seeds (kinds 1..=32)",
193        kinds.len()
194    );
195}
196
197fn main() {
198    let mut args = env::args_os().skip(1);
199    let mode = args.next().expect("mode");
200    let directory = args.next().expect("directory");
201    assert!(args.next().is_none(), "unexpected argument");
202    let directory = Path::new(&directory);
203    if mode == "generate" {
204        fs::create_dir_all(directory).expect("create output");
205        let messages = messages();
206        assert_eq!(messages.len(), 32);
207        for (expected_kind, (name, message)) in (1_u16..=32).zip(messages) {
208            assert_eq!(message.kind(), expected_kind, "{name}");
209            let bytes = encode_frame(&Frame {
210                flags: 0,
211                request: u32::from(expected_kind),
212                message,
213            })
214            .expect("encode seed");
215            assert!(
216                matches!(decode_frame(&bytes), Ok(DecodedFrame::Known(_))),
217                "{name}"
218            );
219            fs::write(
220                directory.join(format!("known-{expected_kind:02}-{name}.bin")),
221                bytes,
222            )
223            .expect("write seed");
224        }
225    } else if mode != "verify" {
226        panic!("mode must be generate or verify");
227    }
228    verify(directory);
229}

Trait Implementations§

Source§

impl Clone for Message

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Message

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl PartialEq for Message

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for Message

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

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.