Enum zenoh::SessionRef

source ·
pub enum SessionRef<'a> {
    Borrow(&'a Session),
    Shared(Arc<Session>),
}

Variants§

§

Borrow(&'a Session)

§

Shared(Arc<Session>)

Methods from Deref<Target = Session>§

source

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.

source

pub fn hlc(&self) -> Option<&HLC>

source

pub fn undeclare<'a, T, O>(&'a self, decl: T) -> O

source

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"]"#);
source

pub fn declare_keyexpr<'a, 'b: 'a, TryIntoKeyExpr>( &'a self, key_expr: TryIntoKeyExpr ) -> impl Resolve<ZResult<KeyExpr<'b>>> + 'a
where TryIntoKeyExpr: TryInto<KeyExpr<'b>>, <TryIntoKeyExpr as TryInto<KeyExpr<'b>>>::Error: Into<Error>,

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();
source

pub fn put<'a, 'b: 'a, TryIntoKeyExpr, IntoValue>( &'a self, key_expr: TryIntoKeyExpr, value: IntoValue ) -> PutBuilder<'a, 'b>
where TryIntoKeyExpr: TryInto<KeyExpr<'b>>, <TryIntoKeyExpr as TryInto<KeyExpr<'b>>>::Error: Into<Error>, IntoValue: Into<Value>,

Put data.

§Arguments
  • key_expr - Key expression matching the resources to put
  • value - 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();
source

pub fn delete<'a, 'b: 'a, TryIntoKeyExpr>( &'a self, key_expr: TryIntoKeyExpr ) -> DeleteBuilder<'a, 'b>
where TryIntoKeyExpr: TryInto<KeyExpr<'b>>, <TryIntoKeyExpr as TryInto<KeyExpr<'b>>>::Error: Into<Error>,

Delete data.

§Arguments
  • key_expr - Key expression matching the resources to delete
§Examples
use zenoh::prelude::r#async::*;

let session = zenoh::open(config::peer()).res().await.unwrap();
session.delete("key/expression").res().await.unwrap();
source

pub fn get<'a, 'b: 'a, TryIntoSelector>( &'a self, selector: TryIntoSelector ) -> GetBuilder<'a, 'b, DefaultHandler>
where TryIntoSelector: TryInto<Selector<'b>>, <TryIntoSelector as TryInto<Selector<'b>>>::Error: Into<Error>,

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>

source§

fn clone(&self) -> SessionRef<'a>

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for SessionRef<'_>

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

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>
where TryIntoKeyExpr: TryInto<KeyExpr<'b>>, <TryIntoKeyExpr as TryInto<KeyExpr<'b>>>::Error: Into<Error>,

Create a Subscriber for the given key expression. Read more
source§

fn declare_queryable<'b, TryIntoKeyExpr>( &'s self, key_expr: TryIntoKeyExpr ) -> QueryableBuilder<'a, 'b, DefaultHandler>
where TryIntoKeyExpr: TryInto<KeyExpr<'b>>, <TryIntoKeyExpr as TryInto<KeyExpr<'b>>>::Error: Into<Error>,

Create a Queryable for the given key expression. Read more
source§

fn declare_publisher<'b, TryIntoKeyExpr>( &'s self, key_expr: TryIntoKeyExpr ) -> PublisherBuilder<'a, 'b>
where TryIntoKeyExpr: TryInto<KeyExpr<'b>>, <TryIntoKeyExpr as TryInto<KeyExpr<'b>>>::Error: Into<Error>,

Create a Publisher for the given key expression. Read more
source§

fn liveliness(&'s self) -> Liveliness<'a>

Available on crate feature unstable only.
Obtain a Liveliness struct tied to this Zenoh Session. Read more
source§

fn info(&'s self) -> SessionInfo<'a>

Get informations about the zenoh Session. Read more
source§

impl Deref for SessionRef<'_>

§

type Target = Session

The resulting type after dereferencing.
source§

fn deref(&self) -> &Self::Target

Dereferences the value.

Auto Trait Implementations§

§

impl<'a> Freeze for SessionRef<'a>

§

impl<'a> !RefUnwindSafe for SessionRef<'a>

§

impl<'a> Send for SessionRef<'a>

§

impl<'a> Sync for SessionRef<'a>

§

impl<'a> Unpin for SessionRef<'a>

§

impl<'a> !UnwindSafe for SessionRef<'a>

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> AsNode<T> for T

source§

fn as_node(&self) -> &T

source§

impl<T> AsNodeMut<T> for T

source§

fn as_node_mut(&mut self) -> &mut T

source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> DynClone for T
where T: Clone,

source§

fn __clone_box(&self, _: Private) -> *mut ()

source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T> Instrument for T

source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> Same for T

§

type Output = T

Should always be Self
source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

source§

fn vzip(self) -> V

source§

impl<T> WithSubscriber for T

source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more