-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathplugin.rs
55 lines (49 loc) · 1.51 KB
/
plugin.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
use std::io::{self, Read, Write};
use crate::bus::{BusInfo, Layout};
use crate::engine::{Config, Engine};
use crate::host::Host;
use crate::params::{ParamId, ParamInfo, ParamValue};
use crate::view::{ParentWindow, View, ViewHost};
pub struct PluginInfo {
pub name: String,
pub version: String,
pub vendor: String,
pub url: String,
pub email: String,
pub buses: Vec<BusInfo>,
pub layouts: Vec<Layout>,
pub params: Vec<ParamInfo>,
pub has_view: bool,
}
#[allow(clippy::derivable_impls)]
impl Default for PluginInfo {
fn default() -> PluginInfo {
PluginInfo {
name: String::new(),
version: String::new(),
vendor: String::new(),
url: String::new(),
email: String::new(),
buses: Vec::new(),
layouts: Vec::new(),
params: Vec::new(),
has_view: false,
}
}
}
pub trait Plugin: Send + Sized + 'static {
type Engine: Engine;
type View: View;
fn info() -> PluginInfo;
fn new(host: Host) -> Self;
fn set_param(&mut self, id: ParamId, value: ParamValue);
fn get_param(&self, id: ParamId) -> ParamValue;
fn save(&self, output: &mut impl Write) -> io::Result<()>;
fn load(&mut self, input: &mut impl Read) -> io::Result<()>;
fn engine(&mut self, config: Config) -> Self::Engine;
fn view(&mut self, host: ViewHost, parent: &ParentWindow) -> Self::View;
#[allow(unused_variables)]
fn latency(&self, config: &Config) -> u64 {
0
}
}