Enum zenoh::SessionRef
source · pub enum SessionRef<'a> {
Borrow(&'a Session),
Shared(Arc<Session>),
}
Variants§
Methods from Deref<Target = Session>§
sourcepub fn zid(&self) -> ZenohId
pub fn zid(&self) -> ZenohId
Returns the identifier of the current session. zid()
is a convenient shortcut.
See Session::info()
and SessionInfo::zid()
for more details.
pub fn hlc(&self) -> Option<&HLC>
pub fn undeclare<'a, T, O>(&'a self, decl: T) -> O
sourcepub fn config(&self) -> &Notifier<Config>
pub fn config(&self) -> &Notifier<Config>
Get the current configuration of the zenoh Session
.
The returned configuration Notifier
can be used to read the current
zenoh configuration through the get
function or
modify the zenoh configuration through the insert
,
or insert_json5
funtion.
§Examples
§Read current zenoh configuration
use zenoh::prelude::r#async::*;
let session = zenoh::open(config::peer()).res().await.unwrap();
let peers = session.config().get("connect/endpoints").unwrap();
§Modify current zenoh configuration
use zenoh::prelude::r#async::*;
let session = zenoh::open(config::peer()).res().await.unwrap();
let _ = session.config().insert_json5("connect/endpoints", r#"["tcp/127.0.0.1/7447"]"#);
sourcepub fn declare_keyexpr<'a, 'b: 'a, TryIntoKeyExpr>(
&'a self,
key_expr: TryIntoKeyExpr
) -> impl Resolve<ZResult<KeyExpr<'b>>> + 'a
pub fn declare_keyexpr<'a, 'b: 'a, TryIntoKeyExpr>( &'a self, key_expr: TryIntoKeyExpr ) -> impl Resolve<ZResult<KeyExpr<'b>>> + 'a
Informs Zenoh that you intend to use key_expr
multiple times and that it should optimize its transmission.
The returned KeyExpr
’s internal structure may differ from what you would have obtained through a simple
key_expr.try_into()
, to save time on detecting the optimizations that have been associated with it.
§Examples
use zenoh::prelude::r#async::*;
let session = zenoh::open(config::peer()).res().await.unwrap();
let key_expr = session.declare_keyexpr("key/expression").res().await.unwrap();
sourcepub fn put<'a, 'b: 'a, TryIntoKeyExpr, IntoValue>(
&'a self,
key_expr: TryIntoKeyExpr,
value: IntoValue
) -> PutBuilder<'a, 'b>
pub fn put<'a, 'b: 'a, TryIntoKeyExpr, IntoValue>( &'a self, key_expr: TryIntoKeyExpr, value: IntoValue ) -> PutBuilder<'a, 'b>
Put data.
§Arguments
key_expr
- Key expression matching the resources to putvalue
- The value to put
§Examples
use zenoh::prelude::r#async::*;
let session = zenoh::open(config::peer()).res().await.unwrap();
session
.put("key/expression", "value")
.encoding(KnownEncoding::TextPlain)
.res()
.await
.unwrap();
sourcepub fn delete<'a, 'b: 'a, TryIntoKeyExpr>(
&'a self,
key_expr: TryIntoKeyExpr
) -> DeleteBuilder<'a, 'b>
pub fn delete<'a, 'b: 'a, TryIntoKeyExpr>( &'a self, key_expr: TryIntoKeyExpr ) -> DeleteBuilder<'a, 'b>
sourcepub fn get<'a, 'b: 'a, TryIntoSelector>(
&'a self,
selector: TryIntoSelector
) -> GetBuilder<'a, 'b, DefaultHandler>
pub fn get<'a, 'b: 'a, TryIntoSelector>( &'a self, selector: TryIntoSelector ) -> GetBuilder<'a, 'b, DefaultHandler>
Query data from the matching queryables in the system.
Unless explicitly requested via GetBuilder::accept_replies
, replies are guaranteed to have
key expressions that match the requested selector
.
§Arguments
selector
- The selection of resources to query
§Examples
use zenoh::prelude::r#async::*;
let session = zenoh::open(config::peer()).res().await.unwrap();
let replies = session.get("key/expression").res().await.unwrap();
while let Ok(reply) = replies.recv_async().await {
println!(">> Received {:?}", reply.sample);
}
Trait Implementations§
source§impl<'a> Clone for SessionRef<'a>
impl<'a> Clone for SessionRef<'a>
source§fn clone(&self) -> SessionRef<'a>
fn clone(&self) -> SessionRef<'a>
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl Debug for SessionRef<'_>
impl Debug for SessionRef<'_>
source§impl<'s, 'a> SessionDeclarations<'s, 'a> for SessionRef<'a>
impl<'s, 'a> SessionDeclarations<'s, 'a> for SessionRef<'a>
source§fn declare_subscriber<'b, TryIntoKeyExpr>(
&'s self,
key_expr: TryIntoKeyExpr
) -> SubscriberBuilder<'a, 'b, PushMode, DefaultHandler>
fn declare_subscriber<'b, TryIntoKeyExpr>( &'s self, key_expr: TryIntoKeyExpr ) -> SubscriberBuilder<'a, 'b, PushMode, DefaultHandler>
Subscriber
for the given key expression. Read moresource§fn declare_queryable<'b, TryIntoKeyExpr>(
&'s self,
key_expr: TryIntoKeyExpr
) -> QueryableBuilder<'a, 'b, DefaultHandler>
fn declare_queryable<'b, TryIntoKeyExpr>( &'s self, key_expr: TryIntoKeyExpr ) -> QueryableBuilder<'a, 'b, DefaultHandler>
source§fn declare_publisher<'b, TryIntoKeyExpr>(
&'s self,
key_expr: TryIntoKeyExpr
) -> PublisherBuilder<'a, 'b>
fn declare_publisher<'b, TryIntoKeyExpr>( &'s self, key_expr: TryIntoKeyExpr ) -> PublisherBuilder<'a, 'b>
source§fn liveliness(&'s self) -> Liveliness<'a>
fn liveliness(&'s self) -> Liveliness<'a>
unstable
only.