zenoh_plugin_trait/
lib.rs

1//
2// Copyright (c) 2023 ZettaScale Technology
3//
4// This program and the accompanying materials are made available under the
5// terms of the Eclipse Public License 2.0 which is available at
6// http://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0
7// which is available at https://www.apache.org/licenses/LICENSE-2.0.
8//
9// SPDX-License-Identifier: EPL-2.0 OR Apache-2.0
10//
11// Contributors:
12//   ZettaScale Zenoh Team, <zenoh@zettascale.tech>
13//
14
15//! # The plugin infrastructure for Zenoh.
16//!
17//! <div class="warning" style="background-color:#fff5d6;">This API has been marked as <strong>unstable</strong>: it works as advertised, but it may be changed in a future release.</div>
18//!
19//! To build a plugin, implement [`Plugin`].
20//!
21//! If building a plugin for [`zenohd`](https://crates.io/crates/zenoh), you should use the types exported in [`zenoh::plugins`](https://docs.rs/zenoh/latest/zenoh/plugins) to fill [`Plugin`]'s associated types.
22//! To check your plugin typing for `zenohd`, have your plugin implement [`zenoh::plugins::ZenohPlugin`](https://docs.rs/zenoh/latest/zenoh/plugins/struct.ZenohPlugin)
23//!
24//! Plugin is a struct which implements the [`Plugin`] trait. This trait has two associated types:
25//! - `StartArgs`: the type of the arguments passed to the plugin's [`start`](Plugin::start) function.
26//! - `Instance`: the type of the plugin's instance.
27//!
28//! The actual work of the plugin is performed by the instance, which is created by the [`start`](Plugin::start) function.
29//!
30//! Plugins are loaded, started and stopped by [`PluginsManager`]. Stopping plugin is just dropping it's instance.
31//!
32//! Plugins can be static and dynamic.
33//!
34//! Static plugin is just a type which implements [`Plugin`] trait. It can be added to [`PluginsManager`] by [`PluginsManager::declare_static_plugin`](crate::manager::PluginsManager::declare_static_plugin) method.
35//!
36//! Dynamic plugin is a shared library which exports set of C-repr (unmangled) functions which allows to check plugin compatibility and create plugin instance. These functions are defined automatically by [`declare_plugin`] macro.
37//!
38mod compatibility;
39mod manager;
40mod plugin;
41mod vtable;
42
43pub use compatibility::{Compatibility, StructVersion};
44pub use manager::{DeclaredPlugin, LoadedPlugin, PluginsManager, StartedPlugin};
45pub use plugin::{
46    Plugin, PluginConditionSetter, PluginControl, PluginDiff, PluginInstance, PluginReport,
47    PluginStartArgs, PluginState, PluginStatus, PluginStatusRec,
48};
49pub use vtable::{PluginLoaderVersion, PluginVTable, PLUGIN_LOADER_VERSION};
50
51#[doc(hidden)]
52pub mod export {
53    pub use git_version;
54}