Skip to content

Commit 2215c6b

Browse files
Fix backend example in docs (#2154)
* remove outdated warning * update example
1 parent c85edf2 commit 2215c6b

File tree

1 file changed

+21
-7
lines changed
  • plugins/zenoh-backend-traits/src

1 file changed

+21
-7
lines changed

plugins/zenoh-backend-traits/src/lib.rs

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,6 @@
1414

1515
//! ⚠️ WARNING ⚠️
1616
//!
17-
//! TODO: The example is outdated, rewrite it
18-
//!
1917
//! This crate should be considered unstable, as in we might change the APIs anytime.
2018
//!
2119
//! This crate provides the traits to be implemented by a zenoh backend library:
@@ -32,18 +30,34 @@
3230
//! use zenoh::{key_expr::OwnedKeyExpr, time::Timestamp, bytes::{ZBytes, Encoding}};
3331
//! use zenoh_backend_traits::*;
3432
//! use zenoh_backend_traits::config::*;
33+
//! use zenoh_plugin_trait::{plugin_long_version, plugin_version, Plugin};
34+
//! use zenoh_result::ZResult;
3535
//! use zenoh_util::ffi::JsonValue;
3636
//!
37-
//! #[no_mangle]
38-
//! pub fn create_volume(config: VolumeConfig) -> zenoh::Result<Box<dyn Volume>> {
39-
//! Ok(Box::new(MyVolumeType { config }))
40-
//! }
4137
//!
42-
//! // Your Backend implementation
38+
//! // Your Backend volume implementation
4339
//! struct MyVolumeType {
4440
//! config: VolumeConfig,
4541
//! }
4642
//!
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+
//!
4761
//! #[async_trait]
4862
//! impl Volume for MyVolumeType {
4963
//! fn get_admin_status(&self) -> JsonValue {

0 commit comments

Comments
 (0)