[−][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(), None).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(), None).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(), None).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
data_kind | |
encoding | |
properties | |
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. NOTE: 16 bits (2 bytes) may be prepended to the serialized message indicating the total lenght in bytes of the message, resulting in the maximum lenght of a message being 65_536 bytes. This is necessary in those stream-oriented transports (e.g., TCP) that do not preserve the boundary of the serialized messages. The length is encoded as little-endian. In any case, the lenght of a message must not exceed 65_535 bytes. |
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. |
QueryTarget | |
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. |
QueryConsolidation | The kind of consolidation that should be applied on replies to a query. |
Reliability | The kind of reliability. |
ResKey | A resource key. |
SubMode | The subscription mode. |
Target | |
ZErrorKind | The kind of zenoh error. |
Functions
open | Open a zenoh-net Session. |
scout | Scout for routers and/or peers. |
Type Definitions
Config | |
DataHandler | The callback that will be called on each data for a CallbackSubscriber. |
Properties | A list of key/value pairs. |
ResourceId | A numerical Id mapped to a resource name with declare_resource. |
ZInt | A zenoh integer. |
ZResult | A zenoh result. |