Struct zenoh::Zenoh [−][src]
The zenoh client API.
Implementations
impl Zenoh
[src]
pub async fn new(config: ConfigProperties) -> ZResult<Zenoh>
[src]
Creates a zenoh API, establishing a zenoh-net session with discovered peers and/or routers.
Arguments
config
- The ConfigProperties for the zenoh session
Examples
use zenoh::*; let zenoh = Zenoh::new(net::config::default()).await.unwrap();
Configuration Properties
ConfigProperties are a set of key/value (u64
/String
) pairs.
Constants for the accepted keys can be found in the config module.
Multiple values are coma separated.
Examples
use zenoh::*; let mut config = net::config::peer(); config.insert(net::config::ZN_LOCAL_ROUTING_KEY, "false".to_string()); config.insert(net::config::ZN_PEER_KEY, "tcp/10.10.10.10:7447,tcp/11.11.11.11:7447".to_string()); let zenoh = Zenoh::new(config).await.unwrap();
ConfigProperties can be built set of key/value (String
/String
) set
of Properties.
Examples
use zenoh::*; let mut config = Properties::default(); config.insert("local_routing".to_string(), "false".to_string()); config.insert("peer".to_string(), "tcp/10.10.10.10:7447,tcp/11.11.11.11:7447".to_string()); let zenoh = Zenoh::new(config.into()).await.unwrap();
pub fn session(&self) -> &Session
[src]
Returns the zenoh-net Session used by this zenoh session. This is for advanced use cases requiring fine usage of the zenoh-net API.
pub async fn router_pid(&self) -> Option<String>
[src]
Returns the PeerId of the zenoh router this zenoh API is connected to (if any). This calls Session::info() and returns the first router pid from the ZN_INFO_ROUTER_PID_KEY property.
pub async fn workspace(&self, prefix: Option<Path>) -> ZResult<Workspace<'_>>
[src]
Creates a Workspace
with an optional Path
as prefix
.
All relative Path
or Selector
used with this Workspace will be relative to the
specified prefix. Not specifying a prefix is equivalent to specifying "/" as prefix,
meaning in this case that all relative paths/selectors will be prependend with "/".
Examples
use zenoh::*; use std::convert::TryInto; let zenoh = Zenoh::new(net::config::default()).await.unwrap(); let workspace = zenoh.workspace(Some("/demo/example".try_into().unwrap())).await.unwrap(); // The following it equivalent to a PUT on "/demo/example/hello". workspace.put( &"hello".try_into().unwrap(), "Hello World!".into() ).await.unwrap();
pub async fn close(self) -> ZResult<()>
[src]
Closes the zenoh API and the associated zenoh-net session.
Note that on drop, the zenoh-net session is also automatically closed. But you may want to use this function to handle errors or close the session synchronously.
Examples
use zenoh::*; let zenoh = Zenoh::new(net::config::default()).await.unwrap(); zenoh.close();
Trait Implementations
Auto Trait Implementations
impl !RefUnwindSafe for Zenoh
[src]
impl Send for Zenoh
[src]
impl Sync for Zenoh
[src]
impl Unpin for Zenoh
[src]
impl !UnwindSafe for Zenoh
[src]
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>,