zenoh 1.7.0

Zenoh: The Zero Overhead Pub/Sub/Query Protocol.
Documentation

Eclipse Zenoh

Eclipse Zenoh: Zero Overhead Pub/Sub, Store/Query and Compute.

Zenoh (pronounce /zeno/) unifies data in motion, data at rest and computations. It carefully blends traditional pub/sub with geo-distributed storages, queries and computations, while retaining a level of time and space efficiency that is well beyond any of the mainstream stacks.

Check the website zenoh.io for more information and installation instructions

See also the roadmap for more detailed technical information.

Zenoh Rust API

The crate zenoh provides the main implementation of the Zenoh network protocol in Rust and the API to use it.

The primary features of Zenoh are

  • Arbitrary network topology support
  • Publish-subscribe and query-reply paradigms
  • Support for a great variety of underlying network protocols
  • Hierarchical keys with glob support (key expressions)
  • Zero-copy data buffers
  • Scouting for nodes in the network
  • Monitor data availability (liveliness)
  • Monitor the interest to published data (matching)
  • Shared memory support
  • Compact and efficient platform-independent data serialization and deserialization (in zenoh-ext)
  • Components for reliable data publishing with retransmissions (AdvancedSubscriber in zenoh-ext)

Usage Examples

Publish and subscribe

Publishing data:

#[tokio::main]
async fn main() {
    let session = zenoh::open(zenoh::Config::default()).await.unwrap();
    session.put("key/expression", "value").await.unwrap();
    session.close().await.unwrap();
}

Subscribing to data:

use futures::prelude::*;
#[tokio::main]
async fn main() {
    let session = zenoh::open(zenoh::Config::default()).await.unwrap();
    let subscriber = session.declare_subscriber("key/expression").await.unwrap();
    while let Ok(sample) = subscriber.recv_async().await {
        println!("Received: {:?}", sample);
    };
}

Query and reply

Declare a queryable:

#[tokio::main]
async fn main() {
    let session = zenoh::open(zenoh::Config::default()).await.unwrap();
    let queryable = session.declare_queryable("key/expression").await.unwrap();
    while let Ok(query) = queryable.recv_async().await {
        query.reply("key/expression", "value").await.unwrap();
    }
}

Request data:

use futures::prelude::*;
#[tokio::main]
async fn main() {
    let session = zenoh::open(zenoh::Config::default()).await.unwrap();
    let replies = session.get("key/expression").await.unwrap();
    while let Ok(reply) = replies.recv_async().await {
        println!(">> Received {:?}", reply.result());
    }
}

Rust 1.75 support

The crate zenoh can be compiled with Rust 1.75.0, but some of its dependencies may require higher Rust versions. To compile zenoh with Rust 1.75, add a dependency on the crate zenoh-pinned-deps-1-75 to your Cargo.toml:

zenoh = "1.5.1"
zenoh-pinned-deps-1-75 = "1.5.1"

Documentation and examples

For more information, see its documentation: https://docs.rs/zenoh and some examples of usage in https://github.com/eclipse-zenoh/zenoh/tree/main/examples