diff --git a/docs/migration_1.0/rust/index.html b/docs/migration_1.0/rust/index.html index da137c93..e13e62b5 100644 --- a/docs/migration_1.0/rust/index.html +++ b/docs/migration_1.0/rust/index.html @@ -1,6 +1,6 @@ Rust · Zenoh - pub/sub, geo distributed storage, query

Rust

Module reorganization

We reorganized the module tree, so import paths are not the same as before. The main difference is that everything should be imported via the root path zenoh::. Here are some examples, but you can look into zenoh/src/lib.rs for the complete list of changes.

// common use
+

Rust

Module reorganization

We reorganized the module tree, so import paths are not the same as before. The main difference is that everything should be imported via the root path zenoh::. Here are some examples, but you can look into zenoh/src/lib.rs for the complete list of changes.

// common use
 use zenoh::config::*;
 use zenoh::{Config, Error, Result};
 
@@ -53,7 +53,8 @@
 let session = zenoh::open(config).wait().unwrap();
 let publisher = session.declare_publisher(&key_expr).wait().unwrap();
 publisher.put(buf).wait().unwrap();
-

Session is now clonable and can be closed easily

Session implements Clone now, so there is no more need to wrap it into an Arc<Session>, and Session::into_arc has been deprecated. All the session methods, except Session::close, works like before, so only the session type will would to be changed.

The session is now closed automatically when the last Session instance is dropped, even if publishers/subscribers/etc. are still alive. Session can also be manually closed using Session::close, which now takes an immutable reference, so it can be called anytime, even if publishers/subscribers/etc. are still alive. +

Session is now clonable and can be closed easily

Session implements Clone now, so there is no more need to wrap it into an Arc<Session>, and Session::into_arc has been deprecated. All the session methods, except Session::close, works like before, so only the session type need to be changed. +As a side effect, Subscriber and Queryable no longer have a generic lifetime parameter. Publisher also looses one of its lifetime parameters, to keep only the one of its key expression.

The session is now closed automatically when the last Session instance is dropped, even if publishers/subscribers/etc. are still alive. Session can also be manually closed using Session::close, which now takes an immutable reference, so it can be called anytime, even if publishers/subscribers/etc. are still alive. Subscriber and queryable of a closed session will no longer receive data; trying to call Session::get, Session::put or Publisher::put will result in an error. Closing session on the fly may save bandwidth on the wire, as it avoids propagating the undeclaration of remaining entities like subscribers/queryables/etc.

let session = zenoh::open(zenoh::config::peer()).await.unwrap();
 let subscriber = session
     .declare_subscriber("key/expression")