Crate zenoh[][src]

Expand description

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();
}

Modules

The network level zenoh API.

Some useful operations for the zenoh API.

Structs

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

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

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

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

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

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

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

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

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

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.

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

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

A Workspace to operate on zenoh.

Creates a ZFuture that is immediately ready with a value.

The zenoh client API.

Enums

The kind of a Change.

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

Traits

Functions

Creates a Path from a string.

Creates a PathExpr from a string.

Creates a Selector from a string.

Creates a ZFuture that is immediately ready with a value.

Type Definitions