Zenobuf
A simple ROS-like framework in Rust, using Zenoh for transport and Protocol Buffers for serialization.
Overview
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
Getting Started
Prerequisites
- Rust 1.70 or later
- Protocol Buffers compiler (
protoc) 3.0 or later
Installation
Add the following to your Cargo.toml:
[]
= "0.1.0"
= "0.1.0"
Usage
Defining Messages
Define your messages using Protocol Buffers:
syntax = "proto3";
package my_messages;
message Point {
float x = 1;
float y = 2;
float z = 3;
}
Step 1: Add dependencies to your Cargo.toml:
[]
= "0.2"
= "0.2"
= "0.13"
= { = "1", = ["full"] }
[]
= "0.13"
Step 2: Create a build.rs file that automatically adds the derive macro:
Step 3: Include the generated code in your lib.rs or main.rs:
That's it! The ZenobufMessage derive macro is automatically added to all your protobuf types.
🚀 Quick Start Template
For the fastest way to get started, copy the starter template which includes:
- Pre-configured
Cargo.tomlandbuild.rs - Example protobuf definitions
- Complete working example with publisher, subscriber, service, and client
- Step-by-step customization guide
Creating a Node
use Node;
async
Publishing Messages
use ;
use Point;
// Create a publisher
let publisher = node
.
.build
.await?;
// Create a message
let point = Point ;
// Publish the message
publisher.publish?;
Subscribing to Messages
use ;
use Point;
// Create a subscriber
let _subscriber = node
.
.build
.await?;
// Spin the node
node.spin.await?;
Creating a Service
use ;
use ;
// Create a service
let _service = node
.
.build
.await?;
// Spin the node
node.spin.await?;
Calling a Service
use ;
use ;
// Create a client
let client = node.?;
// Create a request
let request = AddRequest ;
// Call the service
let response = client.call?;
println!;
Using Parameters
use ;
// Set a parameter
node.set_parameter?;
// Get a parameter
let value: i32 = node.get_parameter?;
println!;
📚 Documentation
Quick Links
- 📖 Getting Started Guide - Complete tutorial from installation to your first app
- 🔧 API Reference - Comprehensive API documentation with examples
- 🏗️ Architecture Guide - System design and internal architecture
- 📦 Crate Documentation - API docs on docs.rs
Examples
See the zenobuf-examples crate for complete examples:
- talker.rs - Publisher example
- listener.rs - Subscriber example
- service.rs - Service example
- client.rs - Client example
- parameters.rs - Parameter example
- complete_app.rs - Complete application
CLI Tools
Install the CLI tools for development and debugging:
# Monitor topics
# List system components
# Call services
# Manage parameters
License
This project is licensed under either of
- Apache License, Version 2.0, (LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0)
- MIT license (LICENSE-MIT or http://opensource.org/licenses/MIT)
at your option.