Module zenoh::net [−][src]
Expand description
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.receiver().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
Structs
A subscriber that provides data through a callback.
DataInfo
Hello message
An iterator over the msgs received from a channel.
A publisher.
An entity able to reply to queries.
Struct used by a Queryable to send replies to queries.
A zenoh value.
A zenoh-net session.
A subscriber that provides data through a stream.
An non-blocking iterator over the msgs received from a channel.
A zenoh error.
Creates a ZFuture that is immediately ready with a value.
A clonable wrapper to a contiguous slice of bytes.
Enums
An error that may be emitted when attempting to wait for a value on a receiver when all senders are dropped and there are no more messages in the channel.
An error that may be emitted when attempting to wait for a value on a receiver with a timeout when the receive operation times out or all senders are dropped and there are no values left in the channel.
An error that may be emitted when attempting to fetch a value on a receiver when there are no
messages in the channel. If there are no messages in the channel and all senders are dropped,
then TryRecvError::Disconnected
will be returned.
The kind of zenoh error.
Traits
Functions
Scout for routers and/or peers.
Creates a ZFuture that is immediately ready with a value.
Type Definitions
The callback that will be called on each data for a CallbackSubscriber.
A zenoh result.