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
//! # Zenobuf Core - A simpler ROS-like framework in Rust
//!
//! Zenobuf is a lightweight, ergonomic framework for building distributed systems in Rust.
//! It provides a publish-subscribe messaging system, a service-based RPC system, and a
//! parameter system, similar to ROS (Robot Operating System) but with a more Rust-idiomatic API.
//!
//! ## Features
//!
//! - **Publish-Subscribe Messaging**: Send and receive messages on topics
//! - **Service-Based RPC**: Request-response communication between nodes
//! - **Parameter System**: Store and retrieve configuration values
//! - **Type-Safe API**: Leverage Rust's type system for compile-time guarantees
//! - **Protocol Buffers Integration**: Use Protocol Buffers for message serialization
//! - **Zenoh Transport**: Efficient pub/sub and query/reply using Zenoh
//!
//! ## Quick Start
//!
//! ### 1. Add Dependencies
//!
//! ```toml
//! [dependencies]
//! zenobuf-core = "0.3"
//! zenobuf-macros = "0.3"
//! prost = "0.14"
//! tokio = { version = "1", features = ["full"] }
//!
//! [build-dependencies]
//! prost-build = "0.14"
//! ```
//!
//! ### 2. Define Messages with Protocol Buffers
//!
//! Create `protos/messages.proto`:
//! ```protobuf
//! syntax = "proto3";
//!
//! package my_app;
//!
//! message Point {
//! float x = 1;
//! float y = 2;
//! float z = 3;
//! }
//! ```
//!
//! ### 3. Setup Build Script
//!
//! Create `build.rs`:
//! ```rust,ignore
//! fn main() -> std::io::Result<()> {
//! prost_build::Config::new()
//! .type_attribute(".", "#[derive(zenobuf_macros::ZenobufMessage)]")
//! .compile_protos(&["protos/messages.proto"], &["protos"])?;
//! Ok(())
//! }
//! ```
//!
//! ### 4. Create a Node and Publisher
//!
//! ```rust,ignore
//! use zenobuf_core::Node;
//!
//! // Include generated protobuf code
//! pub mod proto {
//! include!(concat!(env!("OUT_DIR"), "/my_app.rs"));
//! }
//!
//! #[tokio::main]
//! async fn main() -> Result<(), Box<dyn std::error::Error>> {
//! // Create a node
//! let node = Node::new("my_node").await?;
//!
//! // Create a publisher
//! let publisher = node
//! .publisher::<proto::Point>("points")
//! .build()
//! .await?;
//!
//! // Create and publish a message
//! let point = proto::Point {
//! x: 1.0,
//! y: 2.0,
//! z: 3.0,
//! };
//! publisher.publish(&point)?;
//!
//! Ok(())
//! }
//! ```
//!
//! ### 5. Create a Subscriber
//!
//! ```rust,ignore
//! use zenobuf_core::Node;
//!
//! // Use the same proto module from above
//! # pub mod proto {
//! # include!(concat!(env!("OUT_DIR"), "/my_app.rs"));
//! # }
//!
//! #[tokio::main]
//! async fn main() -> Result<(), Box<dyn std::error::Error>> {
//! let node = Node::new("subscriber_node").await?;
//!
//! // Create a subscriber with a callback
//! let _subscriber = node
//! .subscriber::<proto::Point>("points")
//! .build(|point| {
//! println!("Received point: ({}, {}, {})", point.x, point.y, point.z);
//! })
//! .await?;
//!
//! // Keep the node running
//! node.spin().await?;
//! Ok(())
//! }
//! ```
//!
//! ## Architecture
//!
//! Zenobuf is built around several key concepts:
//!
//! - **[Node]**: The main entry point that manages publishers, subscribers, services, and clients
//! - **[Publisher]**: Sends messages to topics
//! - **[Subscriber]**: Receives messages from topics
//! - **[Service]**: Handles request-response communication
//! - **[Client]**: Makes requests to services
//! - **[Message]**: Trait for types that can be sent over the network
//! - **[QosProfile]**: Quality of Service settings for reliable communication
//!
//! ## Examples
//!
//! For complete examples, see the `zenobuf-examples` crate which includes:
//! - Publisher/Subscriber examples
//! - Service/Client examples
//! - Parameter usage
//! - Complete applications
//!
//! ## Getting Started Template
//!
//! The fastest way to get started is to copy the starter template:
//! ```bash
//! git clone https://github.com/varunkamath/zenobuf
//! cp -r zenobuf/starter-template my-zenobuf-app
//! cd my-zenobuf-app
//! cargo run
//! ```
// Re-export key types
pub use Client;
pub use ;
pub use Message;
pub use ;
pub use Parameter;
pub use Publisher;
pub use ;
pub use Service;
pub use Subscriber;
pub use ;