falco_plugin 0.5.1

High level bindings for the Falco plugin API
Documentation
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
use crate::base::Plugin;
use crate::plugin::base::logger::{FalcoPluginLoggerImpl, FALCO_LOGGER};
use crate::plugin::base::PluginWrapper;
use crate::plugin::error::ffi_result::FfiResult;
use crate::plugin::error::last_error::LastError;
use crate::plugin::schema::{ConfigSchema, ConfigSchemaType};
use crate::plugin::tables::vtable::TablesInput;
use crate::strings::from_ptr::try_str_from_ptr;
use anyhow::Context;
use falco_plugin_api::{
    ss_plugin_init_input, ss_plugin_metric, ss_plugin_rc, ss_plugin_rc_SS_PLUGIN_FAILURE,
    ss_plugin_rc_SS_PLUGIN_SUCCESS, ss_plugin_t,
};
use std::collections::BTreeMap;
use std::ffi::{c_char, CString};
use std::sync::Mutex;

/// Marker trait to mark a plugin as exported to the API
///
/// # Safety
///
/// Only implement this trait if you export the plugin either statically or dynamically
/// to the plugin API. This is handled by the `plugin!` and `static_plugin!` macros, so you
/// should never need to implement this trait manually.
#[diagnostic::on_unimplemented(
    message = "Plugin is not exported",
    note = "use either `plugin!` or `static_plugin!`"
)]
pub unsafe trait BasePluginExported {}

pub extern "C-unwind" fn plugin_get_required_api_version<
    const MAJOR: usize,
    const MINOR: usize,
    const PATCH: usize,
>() -> *const c_char {
    static VERSIONS: Mutex<BTreeMap<(usize, usize, usize), CString>> = Mutex::new(BTreeMap::new());

    let mut version = VERSIONS.lock().unwrap();
    // we only generate the string once and never change or delete it
    // so the pointer should remain valid for the static lifetime
    version
        .entry((MAJOR, MINOR, PATCH))
        .or_insert_with(|| {
            let version = format!("{MAJOR}.{MINOR}.{PATCH}");
            CString::new(version).unwrap()
        })
        .as_ptr()
}

pub extern "C-unwind" fn plugin_get_version<T: Plugin>() -> *const c_char {
    T::PLUGIN_VERSION.as_ptr()
}

pub extern "C-unwind" fn plugin_get_name<T: Plugin>() -> *const c_char {
    T::NAME.as_ptr()
}

pub extern "C-unwind" fn plugin_get_description<T: Plugin>() -> *const c_char {
    T::DESCRIPTION.as_ptr()
}

pub extern "C-unwind" fn plugin_get_contact<T: Plugin>() -> *const c_char {
    T::CONTACT.as_ptr()
}

/// # Safety
///
/// init_input must be null or a valid pointer
pub unsafe extern "C-unwind" fn plugin_init<P: Plugin>(
    init_input: *const ss_plugin_init_input,
    rc: *mut ss_plugin_rc,
) -> *mut falco_plugin_api::ss_plugin_t {
    let res = (|| -> Result<*mut PluginWrapper<P>, anyhow::Error> {
        let init_input = unsafe { init_input.as_ref() }
            .ok_or_else(|| anyhow::anyhow!("Got empty init_input"))?;

        let init_config =
            try_str_from_ptr(&init_input.config).context("Failed to get config string")?;

        let config = P::ConfigType::from_str(init_config).context("Failed to parse config")?;
        if let Some(log_fn) = init_input.log_fn {
            let logger_impl = FalcoPluginLoggerImpl {
                owner: init_input.owner,
                logger_fn: log_fn,
            };

            *FALCO_LOGGER.inner.write().unwrap() = Some(logger_impl);
            log::set_logger(&FALCO_LOGGER).ok();

            #[cfg(debug_assertions)]
            log::set_max_level(log::LevelFilter::Trace);

            #[cfg(not(debug_assertions))]
            log::set_max_level(log::LevelFilter::Info);
        }

        let tables_input =
            TablesInput::try_from(init_input).context("Failed to build tables input")?;

        let last_error = unsafe { LastError::from(init_input)? };

        P::new(tables_input.as_ref(), config)
            .map(|plugin| Box::into_raw(Box::new(PluginWrapper::new(plugin, last_error))))
    })();

    match res {
        Ok(plugin) => {
            unsafe {
                *rc = ss_plugin_rc_SS_PLUGIN_SUCCESS;
            }
            plugin.cast()
        }
        Err(e) => {
            let error_str = format!("{:#}", &e);
            log::error!("Failed to initialize plugin: {error_str}");
            let plugin = Box::new(PluginWrapper::<P>::new_error(error_str));
            unsafe {
                *rc = e.status_code();
            }
            Box::into_raw(plugin).cast()
        }
    }
}

/// # Safety
///
/// schema_type must be null or a valid pointer
pub unsafe extern "C-unwind" fn plugin_get_init_schema<P: Plugin>(
    schema_type: *mut falco_plugin_api::ss_plugin_schema_type,
) -> *const c_char {
    let schema_type = unsafe {
        let Some(schema_type) = schema_type.as_mut() else {
            return std::ptr::null();
        };
        schema_type
    };
    match P::ConfigType::get_schema() {
        ConfigSchemaType::None => {
            *schema_type = falco_plugin_api::ss_plugin_schema_type_SS_PLUGIN_SCHEMA_NONE;
            std::ptr::null()
        }
        ConfigSchemaType::Json(s) => {
            *schema_type = falco_plugin_api::ss_plugin_schema_type_SS_PLUGIN_SCHEMA_JSON;
            s.as_ptr()
        }
    }
}

/// # Safety
///
/// `plugin` must have been created by `init()` and not destroyed since
pub unsafe extern "C-unwind" fn plugin_destroy<P: Plugin>(
    plugin: *mut falco_plugin_api::ss_plugin_t,
) {
    unsafe {
        let plugin = plugin as *mut PluginWrapper<P>;
        let _ = Box::from_raw(plugin);
    }
}

/// # Safety
///
/// `plugin` must be a valid pointer to `PluginWrapper<P>`
pub unsafe extern "C-unwind" fn plugin_get_last_error<P: Plugin>(
    plugin: *mut falco_plugin_api::ss_plugin_t,
) -> *const c_char {
    let plugin = plugin as *mut PluginWrapper<P>;
    match unsafe { plugin.as_mut() } {
        Some(plugin) => plugin.error_buf.as_ptr(),
        None => c"no instance".as_ptr(),
    }
}

pub unsafe extern "C-unwind" fn plugin_set_config<P: Plugin>(
    plugin: *mut falco_plugin_api::ss_plugin_t,
    config_input: *const falco_plugin_api::ss_plugin_set_config_input,
) -> falco_plugin_api::ss_plugin_rc {
    let plugin = plugin as *mut PluginWrapper<P>;
    let plugin = unsafe {
        let Some(plugin) = plugin.as_mut() else {
            return ss_plugin_rc_SS_PLUGIN_FAILURE;
        };
        plugin
    };

    let Some(actual_plugin) = &mut plugin.plugin else {
        return ss_plugin_rc_SS_PLUGIN_FAILURE;
    };

    let res = (|| -> Result<(), anyhow::Error> {
        let config_input = unsafe { config_input.as_ref() }.context("Got NULL config")?;

        let updated_config =
            try_str_from_ptr(&config_input.config).context("Failed to get config string")?;
        let config = P::ConfigType::from_str(updated_config).context("Failed to parse config")?;

        actual_plugin.plugin.set_config(config)
    })();

    res.rc(&mut plugin.error_buf)
}

pub unsafe extern "C-unwind" fn plugin_get_metrics<P: Plugin>(
    plugin: *mut ss_plugin_t,
    num_metrics: *mut u32,
) -> *mut ss_plugin_metric {
    let plugin = plugin as *mut PluginWrapper<P>;
    let num_metrics = unsafe {
        let Some(num_metrics) = num_metrics.as_mut() else {
            return std::ptr::null_mut();
        };
        num_metrics
    };

    let plugin = unsafe {
        let Some(plugin) = plugin.as_mut() else {
            *num_metrics = 0;
            return std::ptr::null_mut();
        };
        plugin
    };

    let Some(actual_plugin) = &mut plugin.plugin else {
        *num_metrics = 0;
        return std::ptr::null_mut();
    };

    plugin.metric_storage.clear();
    for metric in actual_plugin.plugin.get_metrics() {
        plugin.metric_storage.push(metric.as_raw());
    }

    *num_metrics = plugin.metric_storage.len() as u32;
    plugin.metric_storage.as_ptr().cast_mut()
}

#[doc(hidden)]
#[macro_export]
macro_rules! wrap_ffi {
    (
        #[$attr:meta]
        use $mod:path: <$ty:ty>;

    $(unsafe fn $name:ident( $($param:ident: $param_ty:ty),* $(,)*) -> $ret:ty;)*
    ) => {
        $(
        #[$attr]
        pub unsafe extern "C-unwind" fn $name ( $($param: $param_ty),*) -> $ret {
            use $mod as wrappers;

            wrappers::$name::<$ty>($($param),*)
        }
        )*
    }
}

/// # Register a Falco plugin
///
/// This macro must be called at most once in a crate (it generates public functions)
/// with a type implementing [`Plugin`] as the sole parameter:
///
/// ```
/// # use std::ffi::CStr;
/// use falco_plugin::base::Plugin;
/// # use falco_plugin::base::Metric;
/// use falco_plugin::plugin;
/// use falco_plugin::tables::TablesInput;
///
/// struct MyPlugin;
/// impl Plugin for MyPlugin {
///     // ...
/// #    const NAME: &'static CStr = c"sample-plugin-rs";
/// #    const PLUGIN_VERSION: &'static CStr = c"0.0.1";
/// #    const DESCRIPTION: &'static CStr = c"A sample Falco plugin that does nothing";
/// #    const CONTACT: &'static CStr = c"you@example.com";
/// #    type ConfigType = ();
/// #
/// #    fn new(input: Option<&TablesInput>, config: Self::ConfigType)
/// #        -> Result<Self, anyhow::Error> {
/// #        Ok(MyPlugin)
/// #    }
/// #
/// #    fn set_config(&mut self, config: Self::ConfigType) -> Result<(), anyhow::Error> {
/// #        Ok(())
/// #    }
/// #
/// #    fn get_metrics(&mut self) -> impl IntoIterator<Item=Metric> {
/// #        []
/// #    }
/// }
///
/// plugin!(#[no_capabilities] MyPlugin);
/// ```
///
/// It implements a form where you can override the required API version (for example, if
/// you wish to advertise an older version for increased compatibility):
///
/// ```
/// # use std::ffi::CStr;
/// use falco_plugin::base::Plugin;
/// # use falco_plugin::base::Metric;
/// use falco_plugin::plugin;
/// use falco_plugin::tables::TablesInput;
///
/// struct MyPlugin;
/// impl Plugin for MyPlugin {
///     // ...
/// #    const NAME: &'static CStr = c"sample-plugin-rs";
/// #    const PLUGIN_VERSION: &'static CStr = c"0.0.1";
/// #    const DESCRIPTION: &'static CStr = c"A sample Falco plugin that does nothing";
/// #    const CONTACT: &'static CStr = c"you@example.com";
/// #    type ConfigType = ();
/// #
/// #    fn new(input: Option<&TablesInput>, config: Self::ConfigType)
/// #        -> Result<Self, anyhow::Error> {
/// #        Ok(MyPlugin)
/// #    }
/// #
/// #    fn set_config(&mut self, config: Self::ConfigType) -> Result<(), anyhow::Error> {
/// #        Ok(())
/// #    }
/// #
/// #    fn get_metrics(&mut self) -> impl IntoIterator<Item=Metric> {
/// #        []
/// #    }
/// }
///
/// // require version 3.3.0 of the API
/// plugin!(unsafe { 3;3;0 } => #[no_capabilities] MyPlugin);
/// ```
///
/// **Note**: this does not affect the actual version supported in any way. If you use this form,
/// it's **entirely your responsibility** to ensure the advertised version is compatible with the actual
/// version supported by this crate.
#[macro_export]
macro_rules! plugin {
    (unsafe { $maj:expr; $min:expr; $patch:expr } => #[no_capabilities] $ty:ty) => {
        unsafe impl $crate::internals::base::wrappers::BasePluginExported for $ty {}

        $crate::base_plugin_ffi_wrappers!($maj; $min; $patch => #[unsafe(no_mangle)] $ty);
    };
    (unsafe { $maj:expr; $min:expr; $patch:expr } => $ty:ty) => {
        plugin!(unsafe {$maj; $min; $patch} => #[no_capabilities] $ty);

        $crate::ensure_plugin_capabilities!($ty);
    };
    ($(#[$attr:tt])? $ty:ty) => {
        plugin!(
            unsafe {
                falco_plugin::api::PLUGIN_API_VERSION_MAJOR as usize;
                falco_plugin::api::PLUGIN_API_VERSION_MINOR as usize;
                0
            } => $(#[$attr])? $ty
        );
    };
}

/// # Automatically generate the Falco plugin API structure for static plugins
///
/// This macro generates a [`falco_plugin_api::plugin_api`] structure, usable as a statically
/// linked plugin. It automatically handles all supported capabilities, so you need just one
/// invocation, regardless of how many capabilities your plugin supports.
///
/// ## Basic usage
///
/// ```
///# use std::ffi::CStr;
///# use falco_plugin::base::Metric;
/// use falco_plugin::base::Plugin;
/// use falco_plugin::static_plugin;
///# use falco_plugin::tables::TablesInput;
///
///# struct MyPlugin;
///#
/// impl Plugin for MyPlugin {
///     // ...
///#     const NAME: &'static CStr = c"sample-plugin-rs";
///#     const PLUGIN_VERSION: &'static CStr = c"0.0.1";
///#     const DESCRIPTION: &'static CStr = c"A sample Falco plugin that does nothing";
///#     const CONTACT: &'static CStr = c"you@example.com";
///#     type ConfigType = ();
///#
///#     fn new(input: Option<&TablesInput>, config: Self::ConfigType)
///#         -> Result<Self, anyhow::Error> {
///#         Ok(MyPlugin)
///#     }
///#
///#     fn set_config(&mut self, config: Self::ConfigType) -> Result<(), anyhow::Error> {
///#         Ok(())
///#     }
///#
///#     fn get_metrics(&mut self) -> impl IntoIterator<Item=Metric> {
///#         []
///#     }
/// }
///
/// static_plugin!(#[no_capabilities] MY_PLUGIN_API = MyPlugin);
/// ```
///
/// This expands to:
/// ```ignore
/// #[unsafe(no_mangle)]
/// static MY_PLUGIN_API: falco_plugin::api::plugin_api = /* ... */;
/// ```
///
/// The symbols referred to in the API structure are still mangled according to default Rust rules.
///
/// ## Overriding the supported API version
///
/// The macro also implements a form where you can override the required API version (for example,
/// if you wish to advertise an older version for increased compatibility):
///
/// ```
///# use std::ffi::CStr;
///# use falco_plugin::base::Metric;
/// use falco_plugin::base::Plugin;
/// use falco_plugin::static_plugin;
///# use falco_plugin::tables::TablesInput;
///
///# struct MyPlugin;
///#
/// impl Plugin for MyPlugin {
///     // ...
///#     const NAME: &'static CStr = c"sample-plugin-rs";
///#     const PLUGIN_VERSION: &'static CStr = c"0.0.1";
///#     const DESCRIPTION: &'static CStr = c"A sample Falco plugin that does nothing";
///#     const CONTACT: &'static CStr = c"you@example.com";
///#     type ConfigType = ();
///#
///#     fn new(input: Option<&TablesInput>, config: Self::ConfigType)
///#         -> Result<Self, anyhow::Error> {
///#         Ok(MyPlugin)
///#     }
///#
///#     fn set_config(&mut self, config: Self::ConfigType) -> Result<(), anyhow::Error> {
///#         Ok(())
///#     }
///#
///#     fn get_metrics(&mut self) -> impl IntoIterator<Item=Metric> {
///#         []
///#     }
/// }
///
/// // advertise API version 3.3.0
/// static_plugin!(MY_PLUGIN_API @ unsafe { 3;3;0 } = #[no_capabilities] MyPlugin);
/// ```
///
/// **Note**: this does not affect the actual version supported in any way. If you use this form,
/// it's **entirely your responsibility** to ensure the advertised version is compatible with the actual
/// version supported by this crate.
#[macro_export]
macro_rules! static_plugin {
    ($(#[$attr:tt])? $vis:vis $name:ident = $ty:ty) => {
        static_plugin!(
            $vis $name @ unsafe {
                falco_plugin::api::PLUGIN_API_VERSION_MAJOR as usize;
                falco_plugin::api::PLUGIN_API_VERSION_MINOR as usize;
                0
            }
            = $(#[$attr])? $ty
        );
    };
    ($vis:vis $name:ident @ unsafe { $maj:expr; $min:expr; $patch:expr } = #[no_capabilities] $ty:ty) => {
        #[unsafe(no_mangle)]
        $vis static $name: falco_plugin::api::plugin_api = const {
            $crate::base_plugin_ffi_wrappers!($maj; $min; $patch => #[deny(dead_code)] $ty);
            __plugin_base_api()
        };

        // a static plugin automatically exports all capabilities
        unsafe impl $crate::internals::base::wrappers::BasePluginExported for $ty {}
        unsafe impl $crate::internals::async_event::wrappers::AsyncPluginExported for $ty {}
        unsafe impl $crate::internals::extract::wrappers::ExtractPluginExported for $ty {}
        unsafe impl $crate::internals::listen::wrappers::CaptureListenPluginExported for $ty {}
        unsafe impl $crate::internals::parse::wrappers::ParsePluginExported for $ty {}
        unsafe impl $crate::internals::source::wrappers::SourcePluginExported for $ty {}
    };
    ($vis:vis $name:ident @ unsafe { $maj:expr; $min:expr; $patch:expr } = $ty:ty) => {
        static_plugin!($vis $name @ unsafe { $maj; $min; $patch } = #[no_capabilities] $ty);

        $crate::ensure_plugin_capabilities!($ty);
    }
}

#[doc(hidden)]
#[macro_export]
macro_rules! ensure_plugin_capabilities {
    ($ty:ty) => {
        const _: () = {
            use $crate::internals::async_event::wrappers::AsyncPluginFallbackApi;
            use $crate::internals::extract::wrappers::ExtractPluginFallbackApi;
            use $crate::internals::listen::wrappers::CaptureListenFallbackApi;
            use $crate::internals::parse::wrappers::ParsePluginFallbackApi;
            use $crate::internals::source::wrappers::SourcePluginFallbackApi;

            let impls_async =
                $crate::internals::async_event::wrappers::AsyncPluginApi::<$ty>::IMPLEMENTS_ASYNC;
            let impls_extract =
                $crate::internals::extract::wrappers::ExtractPluginApi::<$ty>::IMPLEMENTS_EXTRACT;
            let impls_listen =
                $crate::internals::listen::wrappers::CaptureListenApi::<$ty>::IMPLEMENTS_LISTEN;
            let impls_parse =
                $crate::internals::parse::wrappers::ParsePluginApi::<$ty>::IMPLEMENTS_PARSE;
            let impls_source =
                $crate::internals::source::wrappers::SourcePluginApi::<$ty>::IMPLEMENTS_SOURCE;

            assert!(
                impls_async || impls_extract || impls_listen || impls_parse || impls_source,
                "Plugin must implement at least one capability. If you really want a plugin without capabilities, use the #[no_capabilities] attribute"
            );
        };
    };
}

#[doc(hidden)]
#[macro_export]
macro_rules! base_plugin_ffi_wrappers {
    ($maj:expr; $min:expr; $patch:expr => #[$attr:meta] $ty:ty) => {
        #[$attr]
        pub extern "C-unwind" fn plugin_get_required_api_version() -> *const std::ffi::c_char {
            $crate::internals::base::wrappers::plugin_get_required_api_version::<
                { $maj },
                { $min },
                { $patch },
            >()
        }

        $crate::wrap_ffi! {
            #[$attr]
            use $crate::internals::base::wrappers: <$ty>;

            unsafe fn plugin_get_version() -> *const std::ffi::c_char;
            unsafe fn plugin_get_name() -> *const std::ffi::c_char;
            unsafe fn plugin_get_description() -> *const std::ffi::c_char;
            unsafe fn plugin_get_contact() -> *const std::ffi::c_char;
            unsafe fn plugin_get_init_schema(schema_type: *mut u32) -> *const std::ffi::c_char;
            unsafe fn plugin_init(
                args: *const falco_plugin::api::ss_plugin_init_input,
                rc: *mut i32,
            ) -> *mut falco_plugin::api::ss_plugin_t;
            unsafe fn plugin_destroy(plugin: *mut falco_plugin::api::ss_plugin_t) -> ();
            unsafe fn plugin_get_last_error(
                plugin: *mut falco_plugin::api::ss_plugin_t,
            ) -> *const std::ffi::c_char;
            unsafe fn plugin_set_config(
                plugin: *mut falco_plugin::api::ss_plugin_t,
                config_input: *const falco_plugin::api::ss_plugin_set_config_input,
            ) -> falco_plugin::api::ss_plugin_rc;
            unsafe fn plugin_get_metrics(
                plugin: *mut falco_plugin::api::ss_plugin_t,
                num_metrics: *mut u32,
            ) -> *mut falco_plugin::api::ss_plugin_metric;
        }

        #[allow(dead_code)]
        pub const fn __plugin_base_api() -> falco_plugin::api::plugin_api {
            use $crate::internals::async_event::wrappers::AsyncPluginFallbackApi;
            use $crate::internals::extract::wrappers::ExtractPluginFallbackApi;
            use $crate::internals::listen::wrappers::CaptureListenFallbackApi;
            use $crate::internals::parse::wrappers::ParsePluginFallbackApi;
            use $crate::internals::source::wrappers::SourcePluginFallbackApi;
            falco_plugin::api::plugin_api {
                get_required_api_version: Some(plugin_get_required_api_version),
                get_version: Some(plugin_get_version),
                get_name: Some(plugin_get_name),
                get_description: Some(plugin_get_description),
                get_contact: Some(plugin_get_contact),
                get_init_schema: Some(plugin_get_init_schema),
                init: Some(plugin_init),
                destroy: Some(plugin_destroy),
                get_last_error: Some(plugin_get_last_error),
                __bindgen_anon_1:
                    $crate::internals::source::wrappers::SourcePluginApi::<$ty>::SOURCE_API,
                __bindgen_anon_2:
                    $crate::internals::extract::wrappers::ExtractPluginApi::<$ty>::EXTRACT_API,
                __bindgen_anon_3:
                    $crate::internals::parse::wrappers::ParsePluginApi::<$ty>::PARSE_API,
                __bindgen_anon_4:
                    $crate::internals::async_event::wrappers::AsyncPluginApi::<$ty>::ASYNC_API,
                __bindgen_anon_5:
                    $crate::internals::listen::wrappers::CaptureListenApi::<$ty>::LISTEN_API,
                set_config: Some(plugin_set_config),
                get_metrics: Some(plugin_get_metrics),
            }
        }
    };
}