1pub mod audio_buffer;
4#[doc(hidden)]
5pub mod entry;
6pub mod events;
7pub mod ext;
8#[doc(hidden)]
9pub mod factory;
10#[doc(hidden)]
11pub mod ffi;
12pub mod fixedpoint;
13pub mod host;
14pub mod id;
15pub mod plugin;
16pub mod plugin_features;
17pub mod process;
18pub mod stream;
19pub mod string_sizes;
20pub mod timestamp;
21pub mod version;
22
23pub mod prelude {
24 #[doc(inline)]
25 pub use crate::{
26 Error, entry,
27 events::{self, Event, EventBuilder, InputEvents, OutputEvents},
28 ext::{
29 self, Extensions,
30 audio_ports::{
31 self, AudioPortFlags, AudioPortInfo, AudioPortType, AudioPorts, MonoPorts,
32 StereoPorts,
33 },
34 latency::{self, HostLatency, Latency},
35 log::{self, Severity},
36 note_ports::{self, NoteDialect, NotePortInfo, NotePorts},
37 params::{self, ParamInfo, Params},
38 state::{self, State},
39 },
40 host::{self, Host},
41 id::ClapId,
42 plugin::{self, AudioThread, Plugin},
43 plugin_features,
44 process::{self, Process, Status, Status::Continue},
45 stream::{self, IStream, OStream},
46 };
47}
48
49#[doc(hidden)]
50#[macro_export]
51macro_rules! impl_flags_u32 {
53 ($($Flags:ty),* $(,)?) => {$(
54 impl $Flags {
55 pub const fn set(&self, flags: u32) -> u32 {
56 *self as u32 | flags
57 }
58
59 pub const fn is_set(&self, flags: u32) -> bool {
60 *self as u32 & flags != 0
61 }
62
63 pub const fn clear(&self, flags: u32) -> u32 {
64 !(*self as u32) & flags
65 }
66 }
67
68 impl From<$Flags> for u32 {
69 fn from(value: $Flags) -> Self {
70 value as u32
71 }
72 }
73 )*};
74}
75
76#[derive(Debug)]
77pub enum Error {
78 Events(events::Error),
79 Extension(ext::Error),
80 Factory(factory::Error),
81 Host(host::Error),
82 Id(id::Error),
83 IO(std::io::Error),
84 Plugin(plugin::Error),
85 User(Box<dyn std::error::Error + Send + 'static>),
86}
87
88impl std::fmt::Display for Error {
89 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
90 use Error::*;
91 match self {
92 Events(e) => write!(f, "events: {e}"),
93 Extension(e) => write!(f, "extension: {e}"),
94 Factory(e) => write!(f, "factory: {e}"),
95 Host(e) => write!(f, "host: {e}"),
96 Id(e) => write!(f, "id : {e}"),
97 IO(e) => write!(f, "I/O: {e}"),
98 Plugin(e) => write!(f, "plugin: {e}"),
99 User(e) => write!(f, "user: {e}"),
100 }
101 }
102}
103
104impl std::error::Error for Error {}
105
106impl From<std::io::Error> for Error {
107 fn from(value: std::io::Error) -> Self {
108 Self::IO(value)
109 }
110}
111
112impl From<std::num::ParseFloatError> for Error {
113 fn from(value: std::num::ParseFloatError) -> Self {
114 crate::ext::params::Error::from(value).into()
115 }
116}