[−][src]Struct zenoh::net::Session
A zenoh-net session.
Implementations
impl Session
[src]
pub async fn close(__arg0: Self) -> ZResult<()>
[src]
Close the zenoh-net Session.
Sessions are automatically closed when dropped, but you may want to use this function to handle errors or close the Session asynchronously.
Examples
use zenoh::net::*; let session = open(config::peer()).await.unwrap(); session.close().await.unwrap();
pub async fn info<'_>(&'_ self) -> InfoProperties
[src]
Get informations about the zenoh-net Session.
Examples
use zenoh::net::*; let session = open(config::peer()).await.unwrap(); let info = session.info();
pub async fn declare_resource<'_, '_>(
&'_ self,
resource: &'_ ResKey
) -> ZResult<ResourceId>
[src]
&'_ self,
resource: &'_ ResKey
) -> ZResult<ResourceId>
Associate a numerical Id with the given resource key.
This numerical Id will be used on the network to save bandwidth and ease the retrieval of the concerned resource in the routing tables.
Arguments
resource
- The resource key to map to a numerical Id
Examples
use zenoh::net::*; let session = open(config::peer()).await.unwrap(); let rid = session.declare_resource(&"/resource/name".into()).await.unwrap();
pub async fn undeclare_resource<'_>(&'_ self, rid: ResourceId) -> ZResult<()>
[src]
Undeclare the numerical Id/resource key association previously declared with declare_resource.
Arguments
rid
- The numerical Id to unmap
Examples
use zenoh::net::*; let session = open(config::peer()).await.unwrap(); let rid = session.declare_resource(&"/resource/name".into()).await.unwrap(); session.undeclare_resource(rid).await;
pub async fn declare_publisher<'_, '_, '_>(
&'_ self,
resource: &'_ ResKey
) -> ZResult<Publisher<'_>>
[src]
&'_ self,
resource: &'_ ResKey
) -> ZResult<Publisher<'_>>
Declare a Publisher for the given resource key.
Written resources that match the given key will only be sent on the network if matching subscribers exist in the system.
Arguments
resource
- The resource key to publish
Examples
use zenoh::net::*; let session = open(config::peer()).await.unwrap(); let publisher = session.declare_publisher(&"/resource/name".into()).await.unwrap(); session.write(&"/resource/name".into(), "value".as_bytes().into()).await.unwrap();
pub async fn declare_subscriber<'_, '_, '_, '_>(
&'_ self,
resource: &'_ ResKey,
info: &'_ SubInfo
) -> ZResult<Subscriber<'_>>
[src]
&'_ self,
resource: &'_ ResKey,
info: &'_ SubInfo
) -> ZResult<Subscriber<'_>>
Declare a Subscriber for the given resource key.
Arguments
resource
- The resource key to subscribeinfo
- The SubInfo to configure the subscription
Examples
use zenoh::net::*; use futures::prelude::*; let session = open(config::peer()).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); }
pub async fn declare_callback_subscriber<DataHandler, '_, '_, '_, '_>(
&'_ self,
resource: &'_ ResKey,
info: &'_ SubInfo,
data_handler: DataHandler
) -> ZResult<CallbackSubscriber<'_>> where
DataHandler: FnMut(Sample) + Send + Sync + 'static,
[src]
&'_ self,
resource: &'_ ResKey,
info: &'_ SubInfo,
data_handler: DataHandler
) -> ZResult<CallbackSubscriber<'_>> where
DataHandler: FnMut(Sample) + Send + Sync + 'static,
Declare a CallbackSubscriber for the given resource key.
Arguments
resource
- The resource key to subscribeinfo
- The SubInfo to configure the subscriptiondata_handler
- The callback that will be called on each data reception
Examples
use zenoh::net::*; let session = open(config::peer()).await.unwrap(); let sub_info = SubInfo { reliability: Reliability::Reliable, mode: SubMode::Push, period: None }; let subscriber = session.declare_callback_subscriber(&"/resource/name".into(), &sub_info, |sample| { println!("Received : {} {}", sample.res_name, sample.payload); } ).await.unwrap();
pub async fn declare_queryable<'_, '_, '_>(
&'_ self,
resource: &'_ ResKey,
kind: ZInt
) -> ZResult<Queryable<'_>>
[src]
&'_ self,
resource: &'_ ResKey,
kind: ZInt
) -> ZResult<Queryable<'_>>
Declare a Queryable for the given resource key.
Arguments
Examples
use zenoh::net::*; use zenoh::net::queryable::EVAL; use futures::prelude::*; let session = open(config::peer()).await.unwrap(); let mut queryable = session.declare_queryable(&"/resource/name".into(), EVAL).await.unwrap(); while let Some(query) = queryable.stream().next().await { query.reply(Sample{ res_name: "/resource/name".to_string(), payload: "value".as_bytes().into(), data_info: None, }).await; }
pub async fn write<'_, '_>(
&'_ self,
resource: &'_ ResKey,
payload: RBuf
) -> ZResult<()>
[src]
&'_ self,
resource: &'_ ResKey,
payload: RBuf
) -> ZResult<()>
Write data.
Arguments
resource
- The resource key to writepayload
- The value to write
Examples
use zenoh::net::*; let session = open(config::peer()).await.unwrap(); session.write(&"/resource/name".into(), "value".as_bytes().into()).await.unwrap();
pub async fn write_ext<'_, '_>(
&'_ self,
resource: &'_ ResKey,
payload: RBuf,
encoding: ZInt,
kind: ZInt,
congestion_control: CongestionControl
) -> ZResult<()>
[src]
&'_ self,
resource: &'_ ResKey,
payload: RBuf,
encoding: ZInt,
kind: ZInt,
congestion_control: CongestionControl
) -> ZResult<()>
Write data with options.
Arguments
resource
- The resource key to writepayload
- The value to writeencoding
- The encoding of the valuekind
- The kind of valuecongestion_control
- The value for the congestion control
Examples
use zenoh::net::*; let session = open(config::peer()).await.unwrap(); session.write_ext(&"/resource/name".into(), "value".as_bytes().into(), encoding::TEXT_PLAIN, data_kind::PUT, CongestionControl::Drop).await.unwrap();
pub async fn query<'_, '_, '_>(
&'_ self,
resource: &'_ ResKey,
predicate: &'_ str,
target: QueryTarget,
consolidation: QueryConsolidation
) -> ZResult<Receiver<Reply>>
[src]
&'_ self,
resource: &'_ ResKey,
predicate: &'_ str,
target: QueryTarget,
consolidation: QueryConsolidation
) -> ZResult<Receiver<Reply>>
Query data from the matching queryables in the system.
Arguments
resource
- The resource key to querypredicate
- An indication to matching queryables about the queried datatarget
- The kind of queryables that should be target of this queryconsolidation
- The kind of consolidation that should be applied on replies
Examples
use zenoh::net::*; use futures::prelude::*; let session = open(config::peer()).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); }
Trait Implementations
impl Debug for Session
[src]
impl Drop for Session
[src]
impl Primitives for Session
[src]
fn resource<'life0, 'life1, 'async_trait>(
&'life0 self,
rid: ZInt,
reskey: &'life1 ResKey
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>> where
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
[src]
&'life0 self,
rid: ZInt,
reskey: &'life1 ResKey
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>> where
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
fn forget_resource<'life0, 'async_trait>(
&'life0 self,
_rid: ZInt
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>> where
'life0: 'async_trait,
Self: 'async_trait,
[src]
&'life0 self,
_rid: ZInt
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>> where
'life0: 'async_trait,
Self: 'async_trait,
fn publisher<'life0, 'life1, 'async_trait>(
&'life0 self,
_reskey: &'life1 ResKey
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>> where
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
[src]
&'life0 self,
_reskey: &'life1 ResKey
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>> where
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
fn forget_publisher<'life0, 'life1, 'async_trait>(
&'life0 self,
_reskey: &'life1 ResKey
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>> where
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
[src]
&'life0 self,
_reskey: &'life1 ResKey
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>> where
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
fn subscriber<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
_reskey: &'life1 ResKey,
_sub_info: &'life2 SubInfo
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>> where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Self: 'async_trait,
[src]
&'life0 self,
_reskey: &'life1 ResKey,
_sub_info: &'life2 SubInfo
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>> where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Self: 'async_trait,
fn forget_subscriber<'life0, 'life1, 'async_trait>(
&'life0 self,
_reskey: &'life1 ResKey
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>> where
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
[src]
&'life0 self,
_reskey: &'life1 ResKey
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>> where
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
fn queryable<'life0, 'life1, 'async_trait>(
&'life0 self,
_reskey: &'life1 ResKey
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>> where
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
[src]
&'life0 self,
_reskey: &'life1 ResKey
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>> where
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
fn forget_queryable<'life0, 'life1, 'async_trait>(
&'life0 self,
_reskey: &'life1 ResKey
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>> where
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
[src]
&'life0 self,
_reskey: &'life1 ResKey
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>> where
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
fn data<'life0, 'life1, 'async_trait>(
&'life0 self,
reskey: &'life1 ResKey,
payload: RBuf,
reliability: Reliability,
congestion_control: CongestionControl,
info: Option<DataInfo>
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>> where
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
[src]
&'life0 self,
reskey: &'life1 ResKey,
payload: RBuf,
reliability: Reliability,
congestion_control: CongestionControl,
info: Option<DataInfo>
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>> where
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
fn query<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
reskey: &'life1 ResKey,
predicate: &'life2 str,
qid: ZInt,
target: QueryTarget,
consolidation: QueryConsolidation
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>> where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Self: 'async_trait,
[src]
&'life0 self,
reskey: &'life1 ResKey,
predicate: &'life2 str,
qid: ZInt,
target: QueryTarget,
consolidation: QueryConsolidation
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>> where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Self: 'async_trait,
fn reply_data<'life0, 'async_trait>(
&'life0 self,
qid: ZInt,
source_kind: ZInt,
replier_id: PeerId,
reskey: ResKey,
data_info: Option<DataInfo>,
payload: RBuf
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>> where
'life0: 'async_trait,
Self: 'async_trait,
[src]
&'life0 self,
qid: ZInt,
source_kind: ZInt,
replier_id: PeerId,
reskey: ResKey,
data_info: Option<DataInfo>,
payload: RBuf
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>> where
'life0: 'async_trait,
Self: 'async_trait,
fn reply_final<'life0, 'async_trait>(
&'life0 self,
qid: ZInt
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>> where
'life0: 'async_trait,
Self: 'async_trait,
[src]
&'life0 self,
qid: ZInt
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>> where
'life0: 'async_trait,
Self: 'async_trait,
fn pull<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
_is_final: bool,
_reskey: &'life1 ResKey,
_pull_id: ZInt,
_max_samples: &'life2 Option<ZInt>
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>> where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Self: 'async_trait,
[src]
&'life0 self,
_is_final: bool,
_reskey: &'life1 ResKey,
_pull_id: ZInt,
_max_samples: &'life2 Option<ZInt>
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>> where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Self: 'async_trait,
fn close<'life0, 'async_trait>(
&'life0 self
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>> where
'life0: 'async_trait,
Self: 'async_trait,
[src]
&'life0 self
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>> where
'life0: 'async_trait,
Self: 'async_trait,
Auto Trait Implementations
impl !RefUnwindSafe for Session
impl Send for Session
impl Sync for Session
impl Unpin for Session
impl !UnwindSafe for Session
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> Same<T> for T
type Output = T
Should always be Self
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
pub fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,