Skip to content

Commit

Permalink
feat: update tests and examples
Browse files Browse the repository at this point in the history
  • Loading branch information
jean-roland committed Jun 11, 2024
1 parent ed613b7 commit c1e8c80
Show file tree
Hide file tree
Showing 41 changed files with 142 additions and 128 deletions.
2 changes: 1 addition & 1 deletion examples/arduino/z_get.ino
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ void loop() {
if (strcmp(VALUE, "") != 0) {
z_view_string_t value_str;
z_view_string_wrap(&value_str, VALUE);
z_owned_slice_t payload;
z_owned_bytes_t payload;
z_bytes_encode_from_string(&payload, z_view_string_loan(&value_str));
opts.payload = &payload;
}
Expand Down
8 changes: 4 additions & 4 deletions examples/arduino/z_queryable.ino
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ void query_handler(const z_loaned_query_t *query, void *arg) {
Serial.println("'");

// Process value
const z_loaned_slice_t *payload = z_value_payload(z_query_value(query));
if (z_slice_len(payload) > 0) {
const z_loaned_bytes_t *payload = z_value_payload(z_query_value(query));
if (z_bytes_len(payload) > 0) {
z_owned_string_t payload_string;
z_bytes_decode_into_string(payload, &payload_string);
Serial.print(" with value '");
Expand All @@ -59,10 +59,10 @@ void query_handler(const z_loaned_query_t *query, void *arg) {
// Reply value encoding
z_view_string_t reply_str;
z_view_string_wrap(&reply_str, VALUE);
z_owned_slice_t reply_payload;
z_owned_bytes_t reply_payload;
z_bytes_encode_from_string(&reply_payload, z_view_string_loan(&reply_str));

z_query_reply(query, z_view_keyexpr_loan(&ke), z_slice_move(&reply_payload), NULL);
z_query_reply(query, z_view_keyexpr_loan(&ke), z_bytes_move(&reply_payload), NULL);

z_string_drop(z_string_move(&keystr));
}
Expand Down
4 changes: 2 additions & 2 deletions examples/arduino/z_sub.ino
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@
void data_handler(const z_loaned_sample_t *sample, void *arg) {
z_owned_string_t keystr;
z_keyexpr_to_string(z_sample_keyexpr(sample), &keystr);
const z_loaned_slice_t *slice = z_sample_payload(sample);
std::string val((const char *)z_slice_data(slice), z_slice_len(slice));
const z_loaned_bytes_t *payload = z_sample_payload(sample);
std::string val((const char *)z_bytes_data(payload), z_bytes_len(payload));

Serial.print(" >> [Subscription listener] Received (");
Serial.print(z_string_data(z_string_loan(&keystr)));
Expand Down
2 changes: 1 addition & 1 deletion examples/espidf/z_get.c
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ void app_main() {
if (strcmp(VALUE, "") != 0) {
z_view_string_t value_str;
z_view_string_wrap(&value_str, VALUE);
z_owned_slice_t payload;
z_owned_bytes_t payload;
z_bytes_encode_from_string(&payload, z_loan(value_str));
opts.payload = &payload;
}
Expand Down
6 changes: 3 additions & 3 deletions examples/espidf/z_queryable.c
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,8 @@ void query_handler(const z_loaned_query_t *query, void *ctx) {
printf(" >> [Queryable handler] Received Query '%s%.*s'\n", z_string_data(z_loan(keystr)), (int)z_loan(params)->len,
z_loan(params)->val);
// Process value
const z_loaned_slice_t *payload = z_value_payload(z_query_value(query));
if (z_slice_len(payload) > 0) {
const z_loaned_bytes_t *payload = z_value_payload(z_query_value(query));
if (z_bytes_len(payload) > 0) {
z_owned_string_t payload_string;
z_bytes_decode_into_string(payload, &payload_string);
printf(" with value '%s'\n", z_string_data(z_loan(payload_string)));
Expand All @@ -122,7 +122,7 @@ void query_handler(const z_loaned_query_t *query, void *ctx) {
// Reply value encoding
z_view_string_t reply_str;
z_view_string_wrap(&reply_str, VALUE);
z_owned_slice_t reply_payload;
z_owned_bytes_t reply_payload;
z_bytes_encode_from_string(&reply_payload, z_loan(reply_str));

z_query_reply(query, z_loan(ke), z_move(reply_payload), NULL);
Expand Down
4 changes: 2 additions & 2 deletions examples/espidf/z_sub.c
Original file line number Diff line number Diff line change
Expand Up @@ -103,9 +103,9 @@ void wifi_init_sta(void) {
void data_handler(const z_loaned_sample_t* sample, void* arg) {
z_owned_string_t keystr;
z_keyexpr_to_string(z_sample_keyexpr(sample), &keystr);
const z_loaned_slice_t* payload = z_sample_payload(sample);
const z_loaned_bytes_t* payload = z_sample_payload(sample);
printf(" >> [Subscriber handler] Received ('%s': '%.*s')\n", z_string_data(z_string_loan(&keystr)),
(int)z_slice_len(payload), z_slice_data(payload));
(int)z_bytes_len(payload), z_bytes_data(payload));
z_string_drop(z_string_move(&keystr));
}

Expand Down
2 changes: 1 addition & 1 deletion examples/freertos_plus_tcp/z_get.c
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ void app_main(void) {
if (strcmp(VALUE, "") != 0) {
z_view_string_t value_str;
z_view_string_wrap(&value_str, VALUE);
z_owned_slice_t payload;
z_owned_bytes_t payload;
z_bytes_encode_from_string(&payload, z_loan(value_str));
opts.payload = &payload;
}
Expand Down
6 changes: 3 additions & 3 deletions examples/freertos_plus_tcp/z_queryable.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ void query_handler(const z_loaned_query_t *query, void *ctx) {
printf(" >> [Queryable handler] Received Query '%s%.*s'\n", z_string_data(z_loan(keystr)), (int)z_loan(params)->len,
z_loan(params)->val);
// Process value
const z_loaned_slice_t *payload = z_value_payload(z_query_value(query));
if (z_slice_len(payload) > 0) {
const z_loaned_bytes_t *payload = z_value_payload(z_query_value(query));
if (z_bytes_len(payload) > 0) {
z_owned_string_t payload_string;
z_bytes_decode_into_string(payload, &payload_string);
printf(" with value '%s'\n", z_string_data(z_loan(payload_string)));
Expand All @@ -50,7 +50,7 @@ void query_handler(const z_loaned_query_t *query, void *ctx) {
// Reply value encoding
z_view_string_t reply_str;
z_view_string_wrap(&reply_str, VALUE);
z_owned_slice_t reply_payload;
z_owned_bytes_t reply_payload;
z_bytes_encode_from_string(&reply_payload, z_loan(reply_str));

z_query_reply(query, z_query_keyexpr(query), z_move(reply_payload), &options);
Expand Down
6 changes: 3 additions & 3 deletions examples/freertos_plus_tcp/z_sub.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@ void data_handler(const z_loaned_sample_t *sample, void *ctx) {
(void)(ctx);
z_owned_string_t keystr;
z_keyexpr_to_string(z_sample_keyexpr(sample), &keystr);
const z_loaned_slice_t *payload = z_sample_payload(sample);
printf(">> [Subscriber] Received ('%s': '%.*s')\n", z_string_data(z_loan(keystr)), (int)z_slice_len(payload),
z_slice_data(payload));
const z_loaned_bytes_t *payload = z_sample_payload(sample);
printf(">> [Subscriber] Received ('%s': '%.*s')\n", z_string_data(z_loan(keystr)), (int)z_bytes_len(payload),
z_bytes_data(payload));
z_drop(z_move(keystr));
}

Expand Down
6 changes: 3 additions & 3 deletions examples/freertos_plus_tcp/z_sub_st.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@ void data_handler(const z_loaned_sample_t *sample, void *ctx) {
(void)(ctx);
z_owned_string_t keystr;
z_keyexpr_to_string(z_sample_keyexpr(sample), &keystr);
const z_loaned_slice_t *payload = z_sample_payload(sample);
printf(">> [Subscriber] Received ('%s': '%.*s')\n", z_string_data(z_loan(keystr)), (int)z_slice_len(payload),
z_slice_data(payload));
const z_loaned_bytes_t *payload = z_sample_payload(sample);
printf(">> [Subscriber] Received ('%s': '%.*s')\n", z_string_data(z_loan(keystr)), (int)z_bytes_len(payload),
z_bytes_data(payload));
z_drop(z_move(keystr));
z_drop(z_move(keystr));
msg_nb++;
Expand Down
2 changes: 1 addition & 1 deletion examples/mbed/z_get.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ int main(int argc, char **argv) {
if (strcmp(VALUE, "") != 0) {
z_view_string_t value_str;
z_view_string_wrap(&value_str, VALUE);
z_owned_slice_t payload;
z_owned_bytes_t payload;
z_bytes_encode_from_string(&payload, z_view_string_loan(&value_str));
opts.payload = &payload;
}
Expand Down
8 changes: 4 additions & 4 deletions examples/mbed/z_queryable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ void query_handler(const z_loaned_query_t *query, void *ctx) {
printf(" >> [Queryable handler] Received Query '%s%.*s'\n", z_string_data(z_string_loan(&keystr)),
(int)z_view_string_loan(&pred)->len, z_view_string_loan(&pred)->val);
// Process value
const z_loaned_slice_t *payload = z_value_payload(z_query_value(query));
if (z_slice_len(payload) > 0) {
const z_loaned_bytes_t *payload = z_value_payload(z_query_value(query));
if (z_bytes_len(payload) > 0) {
z_owned_string_t payload_string;
z_bytes_decode_into_string(payload, &payload_string);
printf(" with value '%s'\n", z_string_data(z_string_loan(&payload_string)));
Expand All @@ -50,10 +50,10 @@ void query_handler(const z_loaned_query_t *query, void *ctx) {
// Reply value encoding
z_view_string_t reply_str;
z_view_string_wrap(&reply_str, VALUE);
z_owned_slice_t reply_payload;
z_owned_bytes_t reply_payload;
z_bytes_encode_from_string(&reply_payload, z_view_string_loan(&reply_str));

z_query_reply(query, z_query_keyexpr(query), z_slice_move(&reply_payload), NULL);
z_query_reply(query, z_query_keyexpr(query), z_bytes_move(&reply_payload), NULL);
z_string_drop(z_string_move(&keystr));
}

Expand Down
4 changes: 2 additions & 2 deletions examples/mbed/z_sub.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@
void data_handler(const z_loaned_sample_t *sample, void *arg) {
z_owned_string_t keystr;
z_keyexpr_to_string(z_sample_keyexpr(sample), &keystr);
const z_loaned_slice_t *payload = z_sample_payload(sample);
const z_loaned_bytes_t *payload = z_sample_payload(sample);
printf(" >> [Subscriber handler] Received ('%s': '%.*s')\n", z_string_data(z_string_loan(&keystr)),
(int)z_slice_len(payload), z_slice_data(payload));
(int)z_bytes_len(payload), z_bytes_data(payload));
z_string_drop(z_string_move(&keystr));
}

Expand Down
2 changes: 1 addition & 1 deletion examples/unix/c11/z_get_channel.c
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ int main(int argc, char **argv) {
if (value != NULL) {
z_view_string_t value_str;
z_view_string_wrap(&value_str, value);
z_owned_slice_t payload;
z_owned_bytes_t payload;
z_bytes_encode_from_string(&payload, z_loan(value_str));
opts.payload = &payload;
}
Expand Down
4 changes: 2 additions & 2 deletions examples/unix/c11/z_pong.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
#if Z_FEATURE_SUBSCRIPTION == 1 && Z_FEATURE_PUBLICATION == 1
void callback(const z_loaned_sample_t* sample, void* context) {
const z_loaned_publisher_t* pub = z_loan(*(z_owned_publisher_t*)context);
const z_loaned_slice_t* payload = z_sample_payload(sample);
z_publisher_put(pub, z_slice_data(payload), z_slice_len(payload), NULL);
const z_loaned_bytes_t* payload = z_sample_payload(sample);
z_publisher_put(pub, z_bytes_data(payload), z_bytes_len(payload), NULL);
}
void drop(void* context) {
z_owned_publisher_t* pub = (z_owned_publisher_t*)context;
Expand Down
6 changes: 3 additions & 3 deletions examples/unix/c11/z_pull.c
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,9 @@ int main(int argc, char **argv) {
for (z_call(channel.try_recv, &sample); z_check(sample); z_call(channel.try_recv, &sample)) {
z_owned_string_t keystr;
z_keyexpr_to_string(z_sample_keyexpr(z_loan(sample)), &keystr);
const z_loaned_slice_t *payload = z_sample_payload(z_loan(sample));
printf(">> [Subscriber] Pulled ('%s': '%.*s')\n", z_string_data(z_loan(keystr)), (int)z_slice_len(payload),
z_slice_data(payload));
const z_loaned_bytes_t *payload = z_sample_payload(z_loan(sample));
printf(">> [Subscriber] Pulled ('%s': '%.*s')\n", z_string_data(z_loan(keystr)), (int)z_bytes_len(payload),
z_bytes_data(payload));
z_drop(z_move(keystr));
z_drop(z_move(sample));
}
Expand Down
4 changes: 2 additions & 2 deletions examples/unix/c11/z_queryable.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ void query_handler(const z_loaned_query_t *query, void *ctx) {
z_loan(params)->val);
// Process value
const z_loaned_bytes_t *payload = z_value_payload(z_query_value(query));
if (z_slice_len(payload) > 0) {
if (z_bytes_len(payload) > 0) {
z_owned_string_t payload_string;
z_bytes_decode_into_string(payload, &payload_string);
printf(" with value '%s'\n", z_string_data(z_loan(payload_string)));
Expand Down Expand Up @@ -73,7 +73,7 @@ void query_handler(const z_loaned_query_t *query, void *ctx) {
// Reply value encoding
z_view_string_t reply_str;
z_view_string_wrap(&reply_str, value);
z_owned_slice_t reply_payload;
z_owned_bytes_t reply_payload;
z_bytes_encode_from_string(&reply_payload, z_loan(reply_str));

z_query_reply(query, z_query_keyexpr(query), z_move(reply_payload), &options);
Expand Down
6 changes: 3 additions & 3 deletions examples/unix/c11/z_queryable_channel.c
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,8 @@ int main(int argc, char **argv) {
z_query_parameters(q, &params);
printf(" >> [Queryable handler] Received Query '%s%.*s'\n", z_string_data(z_loan(keystr)),
(int)z_loan(params)->len, z_loan(params)->val);
const z_loaned_slice_t *payload = z_value_payload(z_query_value(z_loan(query)));
if (z_slice_len(payload) > 0) {
const z_loaned_bytes_t *payload = z_value_payload(z_query_value(z_loan(query)));
if (z_bytes_len(payload) > 0) {
z_owned_string_t payload_string;
z_bytes_decode_into_string(payload, &payload_string);
printf(" with value '%s'\n", z_string_data(z_loan(payload_string)));
Expand All @@ -118,7 +118,7 @@ int main(int argc, char **argv) {
// Reply value encoding
z_view_string_t reply_str;
z_view_string_wrap(&reply_str, value);
z_owned_slice_t reply_payload;
z_owned_bytes_t reply_payload;
z_bytes_encode_from_string(&reply_payload, z_loan(reply_str));

z_query_reply(q, z_query_keyexpr(q), z_move(reply_payload), &options);
Expand Down
6 changes: 3 additions & 3 deletions examples/unix/c11/z_sub.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@ void data_handler(const z_loaned_sample_t *sample, void *ctx) {
(void)(ctx);
z_owned_string_t keystr;
z_keyexpr_to_string(z_sample_keyexpr(sample), &keystr);
const z_loaned_slice_t *payload = z_sample_payload(sample);
printf(">> [Subscriber] Received ('%s': '%.*s')\n", z_string_data(z_loan(keystr)), (int)z_slice_len(payload),
z_slice_data(payload));
const z_loaned_bytes_t *payload = z_sample_payload(sample);
printf(">> [Subscriber] Received ('%s': '%.*s')\n", z_string_data(z_loan(keystr)), (int)z_bytes_len(payload),
z_bytes_data(payload));
#if Z_FEATURE_ATTACHMENT == 1
z_attachment_t attachment = z_sample_attachment(sample);
if (z_attachment_check(&attachment)) {
Expand Down
6 changes: 3 additions & 3 deletions examples/unix/c11/z_sub_channel.c
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,9 @@ int main(int argc, char **argv) {
for (z_call(channel.recv, &sample); z_check(sample); z_call(channel.recv, &sample)) {
z_owned_string_t keystr;
z_keyexpr_to_string(z_sample_keyexpr(z_loan(sample)), &keystr);
const z_loaned_slice_t *payload = z_sample_payload(z_loan(sample));
printf(">> [Subscriber] Received ('%s': '%.*s')\n", z_string_data(z_loan(keystr)), (int)z_slice_len(payload),
z_slice_data(payload));
const z_loaned_bytes_t *payload = z_sample_payload(z_loan(sample));
printf(">> [Subscriber] Received ('%s': '%.*s')\n", z_string_data(z_loan(keystr)), (int)z_bytes_len(payload),
z_bytes_data(payload));
z_drop(z_move(keystr));
z_drop(z_move(sample));
z_null(&sample);
Expand Down
6 changes: 3 additions & 3 deletions examples/unix/c11/z_sub_st.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ void data_handler(const z_loaned_sample_t *sample, void *ctx) {
(void)(ctx);
z_owned_string_t keystr;
z_keyexpr_to_string(z_sample_keyexpr(sample), &keystr);
const z_loaned_slice_t *payload = z_sample_payload(sample);
printf(">> [Subscriber] Received ('%s': '%.*s')\n", z_string_data(z_loan(keystr)), (int)z_slice_len(payload),
z_slice_data(payload));
const z_loaned_bytes_t *payload = z_sample_payload(sample);
printf(">> [Subscriber] Received ('%s': '%.*s')\n", z_string_data(z_loan(keystr)), (int)z_bytes_len(payload),
z_bytes_data(payload));
z_drop(z_move(keystr));
msg_nb++;
}
Expand Down
2 changes: 1 addition & 1 deletion examples/unix/c99/z_get.c
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ int main(int argc, char **argv) {
if (value != NULL) {
z_view_string_t value_str;
z_view_string_wrap(&value_str, value);
z_owned_slice_t payload;
z_owned_bytes_t payload;
z_bytes_encode_from_string(&payload, z_view_string_loan(&value_str));
opts.payload = &payload;
}
Expand Down
4 changes: 2 additions & 2 deletions examples/unix/c99/z_pong.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
#if Z_FEATURE_SUBSCRIPTION == 1 && Z_FEATURE_PUBLICATION == 1
void callback(const z_loaned_sample_t* sample, void* context) {
const z_loaned_publisher_t* pub = z_publisher_loan((z_owned_publisher_t*)context);
const z_loaned_slice_t* payload = z_sample_payload(sample);
z_publisher_put(pub, z_slice_data(payload), z_slice_len(payload), NULL);
const z_loaned_bytes_t* payload = z_sample_payload(sample);
z_publisher_put(pub, z_bytes_data(payload), z_bytes_len(payload), NULL);
}
void drop(void* context) {
z_owned_publisher_t* pub = (z_owned_publisher_t*)context;
Expand Down
8 changes: 4 additions & 4 deletions examples/unix/c99/z_queryable.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ void query_handler(const z_loaned_query_t *query, void *ctx) {
printf(" >> [Queryable handler] Received Query '%s%.*s'\n", z_string_data(z_string_loan(&keystr)),
(int)z_view_string_loan(&params)->len, z_view_string_loan(&params)->val);
// Process value
const z_loaned_slice_t *payload = z_value_payload(z_query_value(query));
if (z_slice_len(payload) > 0) {
const z_loaned_bytes_t *payload = z_value_payload(z_query_value(query));
if (z_bytes_len(payload) > 0) {
z_owned_string_t payload_string;
z_bytes_decode_into_string(payload, &payload_string);
printf(" with value '%s'\n", z_string_data(z_string_loan(&payload_string)));
Expand All @@ -48,10 +48,10 @@ void query_handler(const z_loaned_query_t *query, void *ctx) {
// Reply value encoding
z_view_string_t reply_str;
z_view_string_wrap(&reply_str, value);
z_owned_slice_t reply_payload;
z_owned_bytes_t reply_payload;
z_bytes_encode_from_string(&reply_payload, z_view_string_loan(&reply_str));

z_query_reply(query, z_query_keyexpr(query), z_slice_move(&reply_payload), &options);
z_query_reply(query, z_query_keyexpr(query), z_bytes_move(&reply_payload), &options);
z_string_drop(z_string_move(&keystr));
}

Expand Down
4 changes: 2 additions & 2 deletions examples/unix/c99/z_sub.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ void data_handler(const z_loaned_sample_t *sample, void *arg) {
(void)(arg);
z_owned_string_t keystr;
z_keyexpr_to_string(z_sample_keyexpr(sample), &keystr);
const z_loaned_slice_t *payload = z_sample_payload(sample);
const z_loaned_bytes_t *payload = z_sample_payload(sample);
printf(">> [Subscriber] Received ('%s': '%.*s')\n", z_string_data(z_string_loan(&keystr)),
(int)z_slice_len(payload), z_slice_data(payload));
(int)z_bytes_len(payload), z_bytes_data(payload));
z_string_drop(z_string_move(&keystr));
}

Expand Down
4 changes: 2 additions & 2 deletions examples/unix/c99/z_sub_st.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ void data_handler(const z_loaned_sample_t *sample, void *arg) {
(void)(arg);
z_owned_string_t keystr;
z_keyexpr_to_string(z_sample_keyexpr(sample), &keystr);
const z_loaned_slice_t *payload = z_sample_payload(sample);
const z_loaned_bytes_t *payload = z_sample_payload(sample);
printf(">> [Subscriber] Received ('%s': '%.*s')\n", z_string_data(z_string_loan(&keystr)),
(int)z_slice_len(payload), z_slice_data(payload));
(int)z_bytes_len(payload), z_bytes_data(payload));
z_string_drop(z_string_move(&keystr));
msg_nb++;
}
Expand Down
2 changes: 1 addition & 1 deletion examples/windows/z_get.c
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ int main(int argc, char **argv) {
if (value != NULL) {
z_view_string_t value_str;
z_view_string_wrap(&value_str, value);
z_owned_slice_t payload;
z_owned_bytes_t payload;
z_bytes_encode_from_string(&payload, z_loan(value_str));
opts.payload = &payload;
}
Expand Down
4 changes: 2 additions & 2 deletions examples/windows/z_pong.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
#if Z_FEATURE_SUBSCRIPTION == 1 && Z_FEATURE_PUBLICATION == 1
void callback(const z_loaned_sample_t* sample, void* context) {
const z_loaned_publisher_t* pub = z_loan(*(z_owned_publisher_t*)context);
const z_loaned_slice_t* payload = z_sample_payload(sample);
z_publisher_put(pub, z_slice_data(payload), z_slice_len(payload), NULL);
const z_loaned_bytes_t* payload = z_sample_payload(sample);
z_publisher_put(pub, z_bytes_data(payload), z_bytes_len(payload), NULL);
}
void drop(void* context) {
z_owned_publisher_t* pub = (z_owned_publisher_t*)context;
Expand Down
Loading

0 comments on commit c1e8c80

Please sign in to comment.