From 583a11ddd36bb82717ec53032c81c289f3da1d8a Mon Sep 17 00:00:00 2001 From: DenisBiryukov91 Date: Mon, 14 Oct 2024 08:34:55 +0000 Subject: [PATCH] deploy: 0ff9d33c39aca128d0f678f7259b3c3cf0cef821 --- docs/migration_1.0/c_pico/index.html | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/docs/migration_1.0/c_pico/index.html b/docs/migration_1.0/c_pico/index.html index 0c484032..6ad6051c 100644 --- a/docs/migration_1.0/c_pico/index.html +++ b/docs/migration_1.0/c_pico/index.html @@ -1,6 +1,6 @@ C / Pico · Zenoh - pub/sub, geo distributed storage, query

C / Pico

General API changes

We have reworked the type naming to clarify how types should be interacted with.

Owned types

Owned types are allocated by the user and it is their responsibility to drop them using z_drop (or z_close for sessions).

Previously, we were returning Zenoh structures by value. In Zenoh 1.0.0, a reference to memory must be provided. This allows initializing user allocated structures and frees return value for error codes.

Here is a quick example of this change:

  • Zenoh 0.11.x
z_owned_session_t session = z_open(z_move(config));
+

C / Pico

General API changes

We have reworked the type naming to clarify how types should be interacted with.

Owned types

Owned types are allocated by the user and it is their responsibility to drop them using z_drop (or z_close for sessions).

Previously, we were returning Zenoh structures by value. In Zenoh 1.0.0, a reference to memory must be provided. This allows initializing user allocated structures and frees return value for error codes.

Here is a quick example of this change:

  • Zenoh 0.11.x
z_owned_session_t session = z_open(z_move(config));
 if (!z_check(session)) {
     return -1;
 }
@@ -41,7 +41,7 @@
 z_owned_subscriber_t sub;
 z_view_keyexpr_t ke;
 z_view_keyexpr_from_str(&ke, keyexpr);
-if (z_declare_subscriber(&sub, z_loan(session), z_loan(ke), z_move(callback), NULL) < 0) {
+if (z_declare_subscriber(z_loan(session), &sub, z_loan(ke), z_move(callback), NULL) < 0) {
     return -1;
 }
 

Payload and Serialization

Zenoh 1.0.0 handles payload differently. Before one would pass the pointer to the buffer and its length, now everything must be converted/serialized into z_owned_bytes_t.

Raw data in the form of null-terminated strings or buffers (i.e. uint8_t* + length) can be converted directly into z_owned_bytes_t @@ -254,7 +254,6 @@ } }

The same now also works for Subscriber and Queryable :

// callback
-// callback
 void data_handler(const z_loaned_sample_t *sample, void *context) {
   // do something with sample
 }
@@ -262,7 +261,7 @@
 z_owned_closure_sample_t callback;
 z_closure(&callback, data_handler, NULL, NULL);
 z_owned_subscriber_t sub;
-if (z_declare_subscriber(&sub, z_loan(session), z_loan(keyexpr), z_move(callback), NULL) < 0) {
+if (z_declare_subscriber(z_loan(session), &sub, z_loan(keyexpr), z_move(callback), NULL) < 0) {
   printf("Unable to declare subscriber.\n");
   exit(-1);
 }
@@ -272,7 +271,7 @@
 z_owned_closure_sample_t closure;
 z_fifo_channel_reply_new(&closure, &handler, 16);
 z_owned_subscriber_t sub;
-if (z_declare_subscriber(&sub, z_loan(session), z_loan(keyexpr), z_move(closure), NULL) < 0) {
+if (z_declare_subscriber(z_loan(session), &sub, z_loan(keyexpr), z_move(closure), NULL) < 0) {
   printf("Unable to declare subscriber.\n");
   exit(-1);
 }