[][src]Module zenoh::net

The network level zenoh API.

Examples

Publish

use zenoh::net::*;

#[async_std::main]
async fn main() {
    let session = open(config::default()).await.unwrap();
    session.write(&"/resource/name".into(), "value".as_bytes().into()).await.unwrap();
    session.close().await.unwrap();
}

Subscribe

use zenoh::net::*;
use futures::prelude::*;

#[async_std::main]
async fn main() {
    let session = open(config::default()).await.unwrap();
    let sub_info = SubInfo {
        reliability: Reliability::Reliable,
        mode: SubMode::Push,
        period: None
    };
    let mut subscriber = session.declare_subscriber(&"/resource/name".into(), &sub_info).await.unwrap();
    while let Some(sample) = subscriber.stream().next().await { println!("Received : {:?}", sample); };
}

Query

use zenoh::net::*;
use futures::prelude::*;

#[async_std::main]
async fn main() {
    let session = open(config::default()).await.unwrap();
    let mut replies = session.query(
        &"/resource/name".into(),
        "predicate",
        QueryTarget::default(),
        QueryConsolidation::default()
    ).await.unwrap();
    while let Some(reply) = replies.next().await {
        println!(">> Received {:?}", reply.data);
    }
}

Modules

config

Properties to pass to open and scout functions as configuration and associated constants.

data_kind
encoding
info

Properties returned by the info function and associated constants.

queryable
utils
whatami

Structs

CallbackSubscriber

A subscriber that provides data through a callback.

CallbackSubscriberState
DataInfo

Some informations about the associated data.

Hello

A zenoh Hello message.

HelloStream

A stream of Hello messages.

PeerId

The global unique id of a zenoh peer.

Period

A time period.

Publisher

A publisher.

Query

Structs received b y a Queryable.

QueryConsolidation

The kind of consolidation that should be applied on replies to a query at different stages of the reply process.

QueryTarget

The Queryables that should be target of a query.

Queryable

An entity able to reply to queries.

QueryableState
RBuf

A read-only bytes buffer.

RepliesSender

Struct used by a Queryable to send replies to queries.

Reply

Structs returned by a query.

Sample

A zenoh value.

Session

A zenoh-net session.

SubInfo

Informations to configure a subscription.

Subscriber

A subscriber that provides data through a stream.

SubscriberState
WBuf

A writable bytes buffer.

ZError

A zenoh error.

Enums

CongestionControl

The kind of congestion control.

ConsolidationMode

The kind of consolidation.

Reliability

The kind of reliability.

ResKey

A resource key.

SubMode

The subscription mode.

Target

The Queryables that should be target of a query.

ZErrorKind

The kind of zenoh error.

Functions

open

Open a zenoh-net Session.

scout

Scout for routers and/or peers.

Type Definitions

DataHandler

The callback that will be called on each data for a CallbackSubscriber.

ResourceId

A numerical Id mapped to a resource name with declare_resource.

ZInt

A zenoh integer.

ZResult

A zenoh result.