|
14 | 14 |
|
15 | 15 | //! ⚠️ WARNING ⚠️
|
16 | 16 | //!
|
17 |
| -//! TODO: The example is outdated, rewrite it |
18 |
| -//! |
19 | 17 | //! This crate should be considered unstable, as in we might change the APIs anytime.
|
20 | 18 | //!
|
21 | 19 | //! This crate provides the traits to be implemented by a zenoh backend library:
|
|
32 | 30 | //! use zenoh::{key_expr::OwnedKeyExpr, time::Timestamp, bytes::{ZBytes, Encoding}};
|
33 | 31 | //! use zenoh_backend_traits::*;
|
34 | 32 | //! use zenoh_backend_traits::config::*;
|
| 33 | +//! use zenoh_plugin_trait::{plugin_long_version, plugin_version, Plugin}; |
| 34 | +//! use zenoh_result::ZResult; |
35 | 35 | //! use zenoh_util::ffi::JsonValue;
|
36 | 36 | //!
|
37 |
| -//! #[no_mangle] |
38 |
| -//! pub fn create_volume(config: VolumeConfig) -> zenoh::Result<Box<dyn Volume>> { |
39 |
| -//! Ok(Box::new(MyVolumeType { config })) |
40 |
| -//! } |
41 | 37 | //!
|
42 |
| -//! // Your Backend implementation |
| 38 | +//! // Your Backend volume implementation |
43 | 39 | //! struct MyVolumeType {
|
44 | 40 | //! config: VolumeConfig,
|
45 | 41 | //! }
|
46 | 42 | //!
|
| 43 | +//! // Create the entry point for your backend |
| 44 | +//! zenoh_plugin_trait::declare_plugin!(MyVolumeType); |
| 45 | +//! |
| 46 | +//! impl Plugin for MyVolumeType { |
| 47 | +//! type StartArgs = VolumeConfig; |
| 48 | +//! type Instance = VolumeInstance; |
| 49 | +//! fn start(_name: &str, _args: &Self::StartArgs) -> ZResult<Self::Instance> { |
| 50 | +//! let volume = MyVolumeType {config: _args.clone()}; |
| 51 | +//! Ok(Box::new(volume)) |
| 52 | +//! } |
| 53 | +//! |
| 54 | +//! const DEFAULT_NAME: &'static str = "my_backend"; |
| 55 | +//! const PLUGIN_VERSION: &'static str = plugin_version!(); |
| 56 | +//! const PLUGIN_LONG_VERSION: &'static str = plugin_long_version!(); |
| 57 | +//! } |
| 58 | +//! |
| 59 | +//! |
| 60 | +//! |
47 | 61 | //! #[async_trait]
|
48 | 62 | //! impl Volume for MyVolumeType {
|
49 | 63 | //! fn get_admin_status(&self) -> JsonValue {
|
|
0 commit comments