Crate zenoh[][src]

The crate of the zenoh API.

See the Zenoh struct for details.

Quick start examples

Put a key/value into zenoh

use zenoh::*;
use std::convert::TryInto;

#[async_std::main]
async fn main() {
    let zenoh = Zenoh::new(net::config::default()).await.unwrap();
    let workspace = zenoh.workspace(None).await.unwrap();
    workspace.put(
        &"/demo/example/hello".try_into().unwrap(),
        "Hello World!".into()
    ).await.unwrap();
    zenoh.close().await.unwrap();
}

Subscribe for keys/values changes from zenoh

use zenoh::*;
use futures::prelude::*;
use std::convert::TryInto;

#[async_std::main]
async fn main() {
    let zenoh = Zenoh::new(net::config::default()).await.unwrap();
    let workspace = zenoh.workspace(None).await.unwrap();
    let mut change_stream =
        workspace.subscribe(&"/demo/example/**".try_into().unwrap()).await.unwrap();
    while let Some(change) = change_stream.next().await {
        println!(">> {:?} for {} : {:?} at {}",
            change.kind, change.path, change.value, change.timestamp
        )
    }
    change_stream.close().await.unwrap();
    zenoh.close().await.unwrap();
}

Get keys/values from zenoh

use zenoh::*;
use futures::prelude::*;
use std::convert::TryInto;

#[async_std::main]
async fn main() {
    let zenoh = Zenoh::new(net::config::default()).await.unwrap();
    let workspace = zenoh.workspace(None).await.unwrap();
    let mut data_stream = workspace.get(&"/demo/example/**".try_into().unwrap()).await.unwrap();
    while let Some(data) = data_stream.next().await {
        println!(">> {} : {:?} at {}",
            data.path, data.value, data.timestamp
        )
    }
    zenoh.close().await.unwrap();
}

Re-exports

pub use net::protocol::core::TimestampId;

Modules

net

The network level zenoh API.

utils

Some useful operations for the zenoh API.

Structs

Change

The notification of a change occured on a path/value and reported to a subscription.

ChangeStream

A Stream of Change returned as a result of the Workspace::subscribe() operation.

Data

A Data returned as a result of a Workspace::get() operation.

DataStream

A Stream of Data returned as a result of the Workspace::get() operation.

GetRequest

A GET request received by an evaluation function (see Workspace::register_eval()).

GetRequestStream

A Stream of GetRequest returned as a result of the Workspace::register_eval() operation.

Path

A zenoh Path is a set of strings separated by '/' , as in a filesystem path.

PathExpr

A zenoh Path Expression used to express a selection of Paths.

Properties

A map of key/value (String,String) properties.

Selector

A zenoh Selector is the conjunction of a path expression identifying a set of paths and some optional parts allowing to refine the set of paths and associated values.

SubscriberHandle

A handle returned as result of Workspace::subscribe_with_callback() operation.

Timestamp

A timestamp made of a NTP64 and a crate::HLC’s unique identifier.

Workspace

A Workspace to operate on zenoh.

ZError
Zenoh

The zenoh client API.

Enums

ChangeKind

The kind of a Change.

Value

A user value that is associated with a Path in zenoh.

ZErrorKind

Type Definitions

ConfigProperties
ZResult