Module zenoh::net[][src]

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

Re-exports

pub use super::protocol::core::ResourceId;
pub use super::protocol::core::SubInfo;
pub use super::protocol::core::PeerId;
pub use super::protocol::core::Period;
pub use super::protocol::core::Target;
pub use super::protocol::core::QueryTarget;
pub use super::protocol::core::ConsolidationMode;
pub use super::protocol::core::QueryConsolidation;
pub use super::protocol::core::CongestionControl;
pub use super::protocol::core::Reliability;
pub use super::protocol::core::ResKey;
pub use super::protocol::core::SubMode;
pub use super::protocol::core::ZInt;
pub use super::protocol::core::whatami;

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.

plugins
protocol
queryable
routing
runtime
utils

Structs

CallbackSubscriber

A subscriber that provides data through a callback.

DataInfo

DataInfo

Hello

Hello message

HelloStream

A stream of Hello messages.

Publisher

A publisher.

Query

Structs received b y a Queryable.

Queryable

An entity able to reply to queries.

RBuf
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.

SharedMemoryBuf
SharedMemoryBufInfo
SharedMemoryManager
Subscriber

A subscriber that provides data through a stream.

WBuf
ZError

A zenoh error.

Enums

ZErrorKind

The kind of zenoh error.

Functions

open

Open a zenoh-net Session.

scout

Scout for routers and/or peers.

Type Definitions

ConfigProperties
DataHandler

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

ZResult

A zenoh result.