From 2b4e4652551085740333908ea7d812b63e650f48 Mon Sep 17 00:00:00 2001 From: Alexander Date: Mon, 17 Jun 2024 17:41:17 +0200 Subject: [PATCH] Rename (de/en)code to (de)serialize (#424) --- docs/api.rst | 52 +++++++-------- examples/arduino/z_get.ino | 4 +- examples/arduino/z_queryable.ino | 4 +- examples/arduino/z_sub.ino | 2 +- examples/espidf/z_get.c | 4 +- examples/espidf/z_queryable.c | 4 +- examples/espidf/z_sub.c | 2 +- examples/freertos_plus_tcp/z_get.c | 4 +- examples/freertos_plus_tcp/z_queryable.c | 4 +- examples/freertos_plus_tcp/z_sub.c | 2 +- examples/freertos_plus_tcp/z_sub_st.c | 2 +- examples/mbed/z_get.cpp | 4 +- examples/mbed/z_queryable.cpp | 4 +- examples/mbed/z_sub.cpp | 2 +- examples/unix/c11/z_get.c | 4 +- examples/unix/c11/z_get_attachment.c | 19 +++--- examples/unix/c11/z_get_channel.c | 4 +- examples/unix/c11/z_pong.c | 2 +- examples/unix/c11/z_pub_attachment.c | 8 +-- examples/unix/c11/z_pull.c | 2 +- examples/unix/c11/z_queryable.c | 4 +- examples/unix/c11/z_queryable_attachment.c | 19 +++--- examples/unix/c11/z_queryable_channel.c | 4 +- examples/unix/c11/z_sub.c | 2 +- examples/unix/c11/z_sub_attachment.c | 9 +-- examples/unix/c11/z_sub_channel.c | 2 +- examples/unix/c11/z_sub_st.c | 2 +- examples/unix/c99/z_get.c | 4 +- examples/unix/c99/z_pong.c | 2 +- examples/unix/c99/z_queryable.c | 4 +- examples/unix/c99/z_sub.c | 2 +- examples/unix/c99/z_sub_st.c | 2 +- examples/windows/z_get.c | 4 +- examples/windows/z_pong.c | 2 +- examples/windows/z_queryable.c | 4 +- examples/windows/z_sub.c | 2 +- examples/windows/z_sub_st.c | 2 +- examples/zephyr/z_get.c | 4 +- examples/zephyr/z_queryable.c | 4 +- examples/zephyr/z_sub.c | 2 +- include/zenoh-pico/api/primitives.h | 66 +++++++++---------- src/api/api.c | 74 +++++++++++----------- tests/z_api_alignment_test.c | 2 +- tests/z_channels_test.c | 32 +++++----- tests/z_client_test.c | 6 +- tests/z_peer_multicast_test.c | 2 +- tests/z_perf_rx.c | 2 +- tests/z_test_fragment_rx.c | 2 +- 48 files changed, 201 insertions(+), 198 deletions(-) diff --git a/docs/api.rst b/docs/api.rst index f73880a4b..60c969bd5 100644 --- a/docs/api.rst +++ b/docs/api.rst @@ -292,32 +292,32 @@ Primitives .. autocfunction:: primitives.h::z_value_payload .. autocfunction:: primitives.h::z_slice_data .. autocfunction:: primitives.h::z_slice_len -.. autocfunction:: primitives.h::z_bytes_decode_into_int8 -.. autocfunction:: primitives.h::z_bytes_decode_into_int16 -.. autocfunction:: primitives.h::z_bytes_decode_into_int32 -.. autocfunction:: primitives.h::z_bytes_decode_into_int64 -.. autocfunction:: primitives.h::z_bytes_decode_into_uint8 -.. autocfunction:: primitives.h::z_bytes_decode_into_uint16 -.. autocfunction:: primitives.h::z_bytes_decode_into_uint32 -.. autocfunction:: primitives.h::z_bytes_decode_into_uint64 -.. autocfunction:: primitives.h::z_bytes_decode_into_float -.. autocfunction:: primitives.h::z_bytes_decode_into_double -.. autocfunction:: primitives.h::z_bytes_decode_into_slice -.. autocfunction:: primitives.h::z_bytes_decode_into_string -.. autocfunction:: primitives.h::z_bytes_encode_from_int8 -.. autocfunction:: primitives.h::z_bytes_encode_from_int16 -.. autocfunction:: primitives.h::z_bytes_encode_from_int32 -.. autocfunction:: primitives.h::z_bytes_encode_from_int64 -.. autocfunction:: primitives.h::z_bytes_encode_from_uint8 -.. autocfunction:: primitives.h::z_bytes_encode_from_uint16 -.. autocfunction:: primitives.h::z_bytes_encode_from_uint32 -.. autocfunction:: primitives.h::z_bytes_encode_from_uint64 -.. autocfunction:: primitives.h::z_bytes_encode_from_float -.. autocfunction:: primitives.h::z_bytes_encode_from_double -.. autocfunction:: primitives.h::z_bytes_encode_from_slice -.. autocfunction:: primitives.h::z_bytes_encode_from_slice_copy -.. autocfunction:: primitives.h::z_bytes_encode_from_string -.. autocfunction:: primitives.h::z_bytes_encode_from_string_copy +.. autocfunction:: primitives.h::z_bytes_deserialize_into_int8 +.. autocfunction:: primitives.h::z_bytes_deserialize_into_int16 +.. autocfunction:: primitives.h::z_bytes_deserialize_into_int32 +.. autocfunction:: primitives.h::z_bytes_deserialize_into_int64 +.. autocfunction:: primitives.h::z_bytes_deserialize_into_uint8 +.. autocfunction:: primitives.h::z_bytes_deserialize_into_uint16 +.. autocfunction:: primitives.h::z_bytes_deserialize_into_uint32 +.. autocfunction:: primitives.h::z_bytes_deserialize_into_uint64 +.. autocfunction:: primitives.h::z_bytes_deserialize_into_float +.. autocfunction:: primitives.h::z_bytes_deserialize_into_double +.. autocfunction:: primitives.h::z_bytes_deserialize_into_slice +.. autocfunction:: primitives.h::z_bytes_deserialize_into_string +.. autocfunction:: primitives.h::z_bytes_serialize_from_int8 +.. autocfunction:: primitives.h::z_bytes_serialize_from_int16 +.. autocfunction:: primitives.h::z_bytes_serialize_from_int32 +.. autocfunction:: primitives.h::z_bytes_serialize_from_int64 +.. autocfunction:: primitives.h::z_bytes_serialize_from_uint8 +.. autocfunction:: primitives.h::z_bytes_serialize_from_uint16 +.. autocfunction:: primitives.h::z_bytes_serialize_from_uint32 +.. autocfunction:: primitives.h::z_bytes_serialize_from_uint64 +.. autocfunction:: primitives.h::z_bytes_serialize_from_float +.. autocfunction:: primitives.h::z_bytes_serialize_from_double +.. autocfunction:: primitives.h::z_bytes_serialize_from_slice +.. autocfunction:: primitives.h::z_bytes_serialize_from_slice_copy +.. autocfunction:: primitives.h::z_bytes_serialize_from_string +.. autocfunction:: primitives.h::z_bytes_serialize_from_string_copy .. autocfunction:: primitives.h::z_timestamp_check .. autocfunction:: primitives.h::z_query_target_default .. autocfunction:: primitives.h::z_query_consolidation_auto diff --git a/examples/arduino/z_get.ino b/examples/arduino/z_get.ino index 8bbe1fdc3..1194ba3c1 100644 --- a/examples/arduino/z_get.ino +++ b/examples/arduino/z_get.ino @@ -49,7 +49,7 @@ void reply_handler(const z_loaned_reply_t *oreply, void *ctx) { z_owned_string_t keystr; z_keyexpr_to_string(z_sample_keyexpr(sample), &keystr); z_owned_string_t replystr; - z_bytes_decode_into_string(z_sample_payload(sample), &replystr); + z_bytes_deserialize_into_string(z_sample_payload(sample), &replystr); Serial.print(" >> [Get listener] Received ("); Serial.print(z_string_data(z_string_loan(&keystr))); @@ -118,7 +118,7 @@ void loop() { // Value encoding z_owned_bytes_t payload; if (strcmp(VALUE, "") != 0) { - z_bytes_encode_from_string(&payload, VALUE); + z_bytes_serialize_from_string(&payload, VALUE); opts.payload = &payload; } z_owned_closure_reply_t callback; diff --git a/examples/arduino/z_queryable.ino b/examples/arduino/z_queryable.ino index 9ff9b936a..f3d8161c6 100644 --- a/examples/arduino/z_queryable.ino +++ b/examples/arduino/z_queryable.ino @@ -44,7 +44,7 @@ void query_handler(const z_loaned_query_t *query, void *arg) { // Process value z_owned_string_t payload_string; - z_bytes_decode_into_string(z_value_payload(z_query_value(query)), &payload_string); + z_bytes_deserialize_into_string(z_value_payload(z_query_value(query)), &payload_string); if (z_string_len(z_string_loan(&payload_string)) > 1) { Serial.print(" with value '"); Serial.print(z_string_data(z_string_loan(&payload_string))); @@ -57,7 +57,7 @@ void query_handler(const z_loaned_query_t *query, void *arg) { // Reply value encoding z_owned_bytes_t reply_payload; - z_bytes_encode_from_string(&reply_payload, VALUE); + z_bytes_serialize_from_string(&reply_payload, VALUE); z_query_reply(query, z_view_keyexpr_loan(&ke), z_bytes_move(&reply_payload), NULL); diff --git a/examples/arduino/z_sub.ino b/examples/arduino/z_sub.ino index 163368ed7..7e3e90b5b 100644 --- a/examples/arduino/z_sub.ino +++ b/examples/arduino/z_sub.ino @@ -38,7 +38,7 @@ 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); z_owned_string_t value; - z_bytes_decode_into_string(z_sample_payload(sample), &value); + z_bytes_deserialize_into_string(z_sample_payload(sample), &value); Serial.print(" >> [Subscription listener] Received ("); Serial.print(z_string_data(z_string_loan(&keystr))); diff --git a/examples/espidf/z_get.c b/examples/espidf/z_get.c index 959d58c23..bcc607a13 100644 --- a/examples/espidf/z_get.c +++ b/examples/espidf/z_get.c @@ -109,7 +109,7 @@ void reply_handler(const z_loaned_reply_t *oreply, void *ctx) { z_owned_string_t keystr; z_keyexpr_to_string(z_sample_keyexpr(sample), &keystr); z_owned_string_t replystr; - z_bytes_decode_into_string(z_sample_payload(sample), &replystr); + z_bytes_deserialize_into_string(z_sample_payload(sample), &replystr); printf(" >> Received ('%s': '%s')\n", z_string_data(z_loan(keystr)), z_string_data(z_loan(replystr))); z_drop(z_move(keystr)); @@ -165,7 +165,7 @@ void app_main() { // Value encoding z_owned_bytes_t payload; if (strcmp(VALUE, "") != 0) { - z_bytes_encode_from_string(&payload, VALUE); + z_bytes_serialize_from_string(&payload, VALUE); opts.payload = &payload; } z_owned_closure_reply_t callback; diff --git a/examples/espidf/z_queryable.c b/examples/espidf/z_queryable.c index 160d0d475..6d08dc624 100644 --- a/examples/espidf/z_queryable.c +++ b/examples/espidf/z_queryable.c @@ -111,7 +111,7 @@ void query_handler(const z_loaned_query_t *query, void *ctx) { z_loan(params)->val); // Process value z_owned_string_t payload_string; - z_bytes_decode_into_string(z_value_payload(z_query_value(query)), &payload_string); + z_bytes_deserialize_into_string(z_value_payload(z_query_value(query)), &payload_string); if (z_string_len(z_loan(payload_string)) > 1) { printf(" with value '%s'\n", z_string_data(z_loan(payload_string))); } @@ -122,7 +122,7 @@ void query_handler(const z_loaned_query_t *query, void *ctx) { // Reply value encoding z_owned_bytes_t reply_payload; - z_bytes_encode_from_string(&reply_payload, VALUE); + z_bytes_serialize_from_string(&reply_payload, VALUE); z_query_reply(query, z_loan(ke), z_move(reply_payload), NULL); z_drop(z_move(keystr)); diff --git a/examples/espidf/z_sub.c b/examples/espidf/z_sub.c index 278dff3c1..663f4a054 100644 --- a/examples/espidf/z_sub.c +++ b/examples/espidf/z_sub.c @@ -104,7 +104,7 @@ 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); z_owned_string_t value; - z_bytes_decode_into_string(z_sample_payload(sample), &value); + z_bytes_deserialize_into_string(z_sample_payload(sample), &value); printf(" >> [Subscriber handler] Received ('%s': '%s')\n", z_string_data(z_string_loan(&keystr)), z_string_data(z_string_loan(&value))); z_string_drop(z_string_move(&keystr)); diff --git a/examples/freertos_plus_tcp/z_get.c b/examples/freertos_plus_tcp/z_get.c index 671b0501b..51f3b4202 100644 --- a/examples/freertos_plus_tcp/z_get.c +++ b/examples/freertos_plus_tcp/z_get.c @@ -43,7 +43,7 @@ void reply_handler(const z_loaned_reply_t *reply, void *ctx) { z_owned_string_t keystr; z_keyexpr_to_string(z_sample_keyexpr(sample), &keystr); z_owned_string_t replystr; - z_bytes_decode_into_string(z_sample_payload(sample), &replystr); + z_bytes_deserialize_into_string(z_sample_payload(sample), &replystr); printf(">> Received ('%s': '%s')\n", z_string_data(z_loan(keystr)), z_string_data(z_loan(replystr))); z_drop(z_move(keystr)); @@ -89,7 +89,7 @@ void app_main(void) { // Value encoding z_owned_bytes_t payload; if (strcmp(VALUE, "") != 0) { - z_bytes_encode_from_string(&payload, VALUE); + z_bytes_serialize_from_string(&payload, VALUE); opts.payload = &payload; } z_owned_closure_reply_t callback; diff --git a/examples/freertos_plus_tcp/z_queryable.c b/examples/freertos_plus_tcp/z_queryable.c index 923fef662..9110eb380 100644 --- a/examples/freertos_plus_tcp/z_queryable.c +++ b/examples/freertos_plus_tcp/z_queryable.c @@ -39,7 +39,7 @@ void query_handler(const z_loaned_query_t *query, void *ctx) { z_loan(params)->val); // Process value z_owned_string_t payload_string; - z_bytes_decode_into_string(z_value_payload(z_query_value(query)), &payload_string); + z_bytes_deserialize_into_string(z_value_payload(z_query_value(query)), &payload_string); if (z_string_len(z_loan(payload_string)) > 1) { printf(" with value '%s'\n", z_string_data(z_loan(payload_string))); } @@ -49,7 +49,7 @@ void query_handler(const z_loaned_query_t *query, void *ctx) { z_query_reply_options_default(&options); // Reply value encoding z_owned_bytes_t reply_payload; - z_bytes_encode_from_string(&reply_payload, VALUE); + z_bytes_serialize_from_string(&reply_payload, VALUE); z_query_reply(query, z_query_keyexpr(query), z_move(reply_payload), &options); z_drop(z_move(keystr)); diff --git a/examples/freertos_plus_tcp/z_sub.c b/examples/freertos_plus_tcp/z_sub.c index ed923ef4d..7c0caf298 100644 --- a/examples/freertos_plus_tcp/z_sub.c +++ b/examples/freertos_plus_tcp/z_sub.c @@ -33,7 +33,7 @@ void data_handler(const z_loaned_sample_t *sample, void *ctx) { z_owned_string_t keystr; z_keyexpr_to_string(z_sample_keyexpr(sample), &keystr); z_owned_string_t value; - z_bytes_decode_into_string(z_sample_payload(sample), &value); + z_bytes_deserialize_into_string(z_sample_payload(sample), &value); printf(">> [Subscriber] Received ('%s': '%s')\n", z_string_data(z_loan(keystr)), z_string_data(z_loan(value))); z_drop(z_move(keystr)); z_drop(z_move(value)); diff --git a/examples/freertos_plus_tcp/z_sub_st.c b/examples/freertos_plus_tcp/z_sub_st.c index 40c0e613f..05f935516 100644 --- a/examples/freertos_plus_tcp/z_sub_st.c +++ b/examples/freertos_plus_tcp/z_sub_st.c @@ -36,7 +36,7 @@ void data_handler(const z_loaned_sample_t *sample, void *ctx) { z_owned_string_t keystr; z_keyexpr_to_string(z_sample_keyexpr(sample), &keystr); z_owned_string_t value; - z_bytes_decode_into_string(z_sample_payload(sample), &value); + z_bytes_deserialize_into_string(z_sample_payload(sample), &value); printf(">> [Subscriber] Received ('%s': '%s')\n", z_string_data(z_loan(keystr)), z_string_data(z_loan(value))); z_drop(z_move(keystr)); z_drop(z_move(value)); diff --git a/examples/mbed/z_get.cpp b/examples/mbed/z_get.cpp index 215788be8..d8fa2c020 100644 --- a/examples/mbed/z_get.cpp +++ b/examples/mbed/z_get.cpp @@ -39,7 +39,7 @@ void reply_handler(const z_loaned_reply_t *oreply, void *ctx) { z_owned_string_t keystr; z_keyexpr_to_string(z_sample_keyexpr(sample), &keystr); z_owned_string_t replystr; - z_bytes_decode_into_string(z_sample_payload(sample), &replystr); + z_bytes_deserialize_into_string(z_sample_payload(sample), &replystr); printf(" >> Received ('%s': '%s')\n", z_string_data(z_string_loan(&keystr)), z_string_data(z_string_loan(&replystr))); @@ -86,7 +86,7 @@ int main(int argc, char **argv) { // Value encoding z_owned_bytes_t payload; if (strcmp(VALUE, "") != 0) { - z_bytes_encode_from_string(&payload, VALUE); + z_bytes_serialize_from_string(&payload, VALUE); opts.payload = &payload; } z_owned_closure_reply_t callback; diff --git a/examples/mbed/z_queryable.cpp b/examples/mbed/z_queryable.cpp index 12b34dcb9..d00cee73d 100644 --- a/examples/mbed/z_queryable.cpp +++ b/examples/mbed/z_queryable.cpp @@ -41,7 +41,7 @@ void query_handler(const z_loaned_query_t *query, void *ctx) { (int)z_view_string_loan(&pred)->len, z_view_string_loan(&pred)->val); // Process value z_owned_string_t payload_string; - z_bytes_decode_into_string(z_value_payload(z_query_value(query)), &payload_string); + z_bytes_deserialize_into_string(z_value_payload(z_query_value(query)), &payload_string); if (z_string_len(z_string_loan(&payload_string)) > 1) { printf(" with value '%s'\n", z_string_data(z_string_loan(&payload_string))); } @@ -49,7 +49,7 @@ void query_handler(const z_loaned_query_t *query, void *ctx) { // Reply value encoding z_owned_bytes_t reply_payload; - z_bytes_encode_from_string(&reply_payload, VALUE); + z_bytes_serialize_from_string(&reply_payload, VALUE); z_query_reply(query, z_query_keyexpr(query), z_bytes_move(&reply_payload), NULL); z_string_drop(z_string_move(&keystr)); diff --git a/examples/mbed/z_sub.cpp b/examples/mbed/z_sub.cpp index 4cb1e9b89..2b36ecf62 100644 --- a/examples/mbed/z_sub.cpp +++ b/examples/mbed/z_sub.cpp @@ -34,7 +34,7 @@ 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); z_owned_string_t value; - z_bytes_decode_into_string(z_sample_payload(sample), &value); + z_bytes_deserialize_into_string(z_sample_payload(sample), &value); printf(" >> [Subscriber handler] Received ('%s': '%s')\n", z_string_data(z_string_loan(&keystr)), z_string_data(z_string_loan(&value))); z_string_drop(z_string_move(&keystr)); diff --git a/examples/unix/c11/z_get.c b/examples/unix/c11/z_get.c index f026674f0..2375766aa 100644 --- a/examples/unix/c11/z_get.c +++ b/examples/unix/c11/z_get.c @@ -36,7 +36,7 @@ void reply_handler(const z_loaned_reply_t *reply, void *ctx) { z_owned_string_t keystr; z_keyexpr_to_string(z_sample_keyexpr(sample), &keystr); z_owned_string_t replystr; - z_bytes_decode_into_string(z_sample_payload(sample), &replystr); + z_bytes_deserialize_into_string(z_sample_payload(sample), &replystr); printf(">> Received ('%s': '%s')\n", z_string_data(z_loan(keystr)), z_string_data(z_loan(replystr))); z_drop(z_move(keystr)); @@ -123,7 +123,7 @@ int main(int argc, char **argv) { // Value encoding z_owned_bytes_t payload; if (value != NULL) { - z_bytes_encode_from_string(&payload, value); + z_bytes_serialize_from_string(&payload, value); opts.payload = &payload; } diff --git a/examples/unix/c11/z_get_attachment.c b/examples/unix/c11/z_get_attachment.c index ca549a9e1..f807ee51b 100644 --- a/examples/unix/c11/z_get_attachment.c +++ b/examples/unix/c11/z_get_attachment.c @@ -63,9 +63,9 @@ _Bool create_attachment_iter(z_owned_bytes_t *kv_pair, void *context, size_t *cu if (kvs->current_idx >= kvs->len) { return false; } else { - z_bytes_encode_from_string(&k, kvs->data[kvs->current_idx].key); - z_bytes_encode_from_string(&v, kvs->data[kvs->current_idx].value); - zp_bytes_encode_from_pair(kv_pair, z_move(k), z_move(v), curr_idx); + z_bytes_serialize_from_string(&k, kvs->data[kvs->current_idx].key); + z_bytes_serialize_from_string(&v, kvs->data[kvs->current_idx].value); + zp_bytes_serialize_from_pair(kv_pair, z_move(k), z_move(v), curr_idx); kvs->current_idx++; return true; } @@ -74,9 +74,10 @@ _Bool create_attachment_iter(z_owned_bytes_t *kv_pair, void *context, size_t *cu void parse_attachment(kv_pairs_rx_t *kvp, const z_loaned_bytes_t *attachment) { size_t curr_idx = 0; z_owned_bytes_t first, second; - while ((kvp->current_idx < kvp->len) && (zp_bytes_decode_into_pair(attachment, &first, &second, &curr_idx) == 0)) { - z_bytes_decode_into_string(z_loan(first), &kvp->data[kvp->current_idx].key); - z_bytes_decode_into_string(z_loan(second), &kvp->data[kvp->current_idx].value); + while ((kvp->current_idx < kvp->len) && + (zp_bytes_deserialize_into_pair(attachment, &first, &second, &curr_idx) == 0)) { + z_bytes_deserialize_into_string(z_loan(first), &kvp->data[kvp->current_idx].key); + z_bytes_deserialize_into_string(z_loan(second), &kvp->data[kvp->current_idx].value); z_bytes_drop(&first); z_bytes_drop(&second); kvp->current_idx++; @@ -113,7 +114,7 @@ void reply_handler(const z_loaned_reply_t *reply, void *ctx) { z_owned_string_t keystr; z_keyexpr_to_string(z_sample_keyexpr(sample), &keystr); z_owned_string_t replystr; - z_bytes_decode_into_string(z_sample_payload(sample), &replystr); + z_bytes_deserialize_into_string(z_sample_payload(sample), &replystr); printf(">> Received ('%s': '%s')\n", z_string_data(z_loan(keystr)), z_string_data(z_loan(replystr))); @@ -210,7 +211,7 @@ int main(int argc, char **argv) { // Value encoding z_owned_bytes_t payload; if (value != NULL) { - z_bytes_encode_from_string(&payload, value); + z_bytes_serialize_from_string(&payload, value); opts.payload = &payload; } @@ -219,7 +220,7 @@ int main(int argc, char **argv) { kvs[0] = (kv_pair_t){.key = "test_key", .value = "test_value"}; kv_pairs_tx_t ctx = (kv_pairs_tx_t){.data = kvs, .current_idx = 0, .len = 1}; z_owned_bytes_t attachment; - zp_bytes_encode_from_iter(&attachment, create_attachment_iter, (void *)&ctx, kv_pairs_size(&ctx)); + zp_bytes_serialize_from_iter(&attachment, create_attachment_iter, (void *)&ctx, kv_pairs_size(&ctx)); opts.attachment = z_move(attachment); z_owned_closure_reply_t callback; diff --git a/examples/unix/c11/z_get_channel.c b/examples/unix/c11/z_get_channel.c index 0091e14a5..b7cdff16d 100644 --- a/examples/unix/c11/z_get_channel.c +++ b/examples/unix/c11/z_get_channel.c @@ -93,7 +93,7 @@ int main(int argc, char **argv) { // Value encoding z_owned_bytes_t payload; if (value != NULL) { - z_bytes_encode_from_string(&payload, value); + z_bytes_serialize_from_string(&payload, value); opts.payload = &payload; } z_owned_reply_ring_channel_t channel; @@ -111,7 +111,7 @@ int main(int argc, char **argv) { z_owned_string_t keystr; z_keyexpr_to_string(z_sample_keyexpr(sample), &keystr); z_owned_string_t replystr; - z_bytes_decode_into_string(z_sample_payload(sample), &replystr); + z_bytes_deserialize_into_string(z_sample_payload(sample), &replystr); printf(">> Received ('%s': '%s')\n", z_string_data(z_loan(keystr)), z_string_data(z_loan(replystr))); z_drop(z_move(keystr)); diff --git a/examples/unix/c11/z_pong.c b/examples/unix/c11/z_pong.c index 6b7514bc4..c7e56e5d0 100644 --- a/examples/unix/c11/z_pong.c +++ b/examples/unix/c11/z_pong.c @@ -19,7 +19,7 @@ void callback(const z_loaned_sample_t* sample, void* context) { const z_loaned_publisher_t* pub = z_loan(*(z_owned_publisher_t*)context); z_owned_slice_t value; - z_bytes_decode_into_slice(z_sample_payload(sample), &value); + z_bytes_deserialize_into_slice(z_sample_payload(sample), &value); z_publisher_put(pub, z_slice_data(z_loan(value)), z_slice_len(z_loan(value)), NULL); z_drop(z_move(value)); } diff --git a/examples/unix/c11/z_pub_attachment.c b/examples/unix/c11/z_pub_attachment.c index 4f7f30168..5db64ca4e 100644 --- a/examples/unix/c11/z_pub_attachment.c +++ b/examples/unix/c11/z_pub_attachment.c @@ -53,9 +53,9 @@ _Bool create_attachment_iter(z_owned_bytes_t *kv_pair, void *context, size_t *cu if (kvs->current_idx >= kvs->len) { return false; } else { - z_bytes_encode_from_string(&k, kvs->data[kvs->current_idx].key); - z_bytes_encode_from_string(&v, kvs->data[kvs->current_idx].value); - zp_bytes_encode_from_pair(kv_pair, z_move(k), z_move(v), curr_idx); + z_bytes_serialize_from_string(&k, kvs->data[kvs->current_idx].key); + z_bytes_serialize_from_string(&v, kvs->data[kvs->current_idx].value); + zp_bytes_serialize_from_pair(kv_pair, z_move(k), z_move(v), curr_idx); kvs->current_idx++; return true; } @@ -163,7 +163,7 @@ int main(int argc, char **argv) { sprintf(buf_ind, "%d", idx); kvs[1] = (kv_pair_t){.key = "index", .value = buf_ind}; kv_pairs_t ctx = (kv_pairs_t){.data = kvs, .current_idx = 0, .len = 2}; - zp_bytes_encode_from_iter(&attachment, create_attachment_iter, (void *)&ctx, kv_pairs_size(&ctx)); + zp_bytes_serialize_from_iter(&attachment, create_attachment_iter, (void *)&ctx, kv_pairs_size(&ctx)); options.attachment = z_move(attachment); sprintf(buf, "[%4d] %s", idx, value); diff --git a/examples/unix/c11/z_pull.c b/examples/unix/c11/z_pull.c index 7dab57c57..b301d6222 100644 --- a/examples/unix/c11/z_pull.c +++ b/examples/unix/c11/z_pull.c @@ -91,7 +91,7 @@ int main(int argc, char **argv) { z_owned_string_t keystr; z_keyexpr_to_string(z_sample_keyexpr(z_loan(sample)), &keystr); z_owned_string_t value; - z_bytes_decode_into_string(z_sample_payload(z_loan(sample)), &value); + z_bytes_deserialize_into_string(z_sample_payload(z_loan(sample)), &value); printf(">> [Subscriber] Pulled ('%s': '%s')\n", z_string_data(z_loan(keystr)), z_string_data(z_loan(value))); z_drop(z_move(keystr)); diff --git a/examples/unix/c11/z_queryable.c b/examples/unix/c11/z_queryable.c index acf3681bc..3e7a273f9 100644 --- a/examples/unix/c11/z_queryable.c +++ b/examples/unix/c11/z_queryable.c @@ -33,7 +33,7 @@ void query_handler(const z_loaned_query_t *query, void *ctx) { z_loan(params)->val); // Process value z_owned_string_t payload_string; - z_bytes_decode_into_string(z_value_payload(z_query_value(query)), &payload_string); + z_bytes_deserialize_into_string(z_value_payload(z_query_value(query)), &payload_string); if (z_string_len(z_loan(payload_string)) > 1) { printf(" with value '%s'\n", z_string_data(z_loan(payload_string))); } @@ -49,7 +49,7 @@ void query_handler(const z_loaned_query_t *query, void *ctx) { // Reply value encoding z_owned_bytes_t reply_payload; - z_bytes_encode_from_string(&reply_payload, value); + z_bytes_serialize_from_string(&reply_payload, value); z_query_reply(query, z_query_keyexpr(query), z_move(reply_payload), &options); z_drop(z_move(keystr)); diff --git a/examples/unix/c11/z_queryable_attachment.c b/examples/unix/c11/z_queryable_attachment.c index 6c6ecc1ef..a000a58c0 100644 --- a/examples/unix/c11/z_queryable_attachment.c +++ b/examples/unix/c11/z_queryable_attachment.c @@ -64,9 +64,9 @@ _Bool create_attachment_iter(z_owned_bytes_t *kv_pair, void *context, size_t *cu if (kvs->current_idx >= kvs->len) { return false; } else { - z_bytes_encode_from_string(&k, kvs->data[kvs->current_idx].key); - z_bytes_encode_from_string(&v, kvs->data[kvs->current_idx].value); - zp_bytes_encode_from_pair(kv_pair, z_move(k), z_move(v), curr_idx); + z_bytes_serialize_from_string(&k, kvs->data[kvs->current_idx].key); + z_bytes_serialize_from_string(&v, kvs->data[kvs->current_idx].value); + zp_bytes_serialize_from_pair(kv_pair, z_move(k), z_move(v), curr_idx); kvs->current_idx++; return true; } @@ -75,9 +75,10 @@ _Bool create_attachment_iter(z_owned_bytes_t *kv_pair, void *context, size_t *cu void parse_attachment(kv_pairs_rx_t *kvp, const z_loaned_bytes_t *attachment) { size_t curr_idx = 0; z_owned_bytes_t first, second; - while ((kvp->current_idx < kvp->len) && (zp_bytes_decode_into_pair(attachment, &first, &second, &curr_idx) == 0)) { - z_bytes_decode_into_string(z_loan(first), &kvp->data[kvp->current_idx].key); - z_bytes_decode_into_string(z_loan(second), &kvp->data[kvp->current_idx].value); + while ((kvp->current_idx < kvp->len) && + (zp_bytes_deserialize_into_pair(attachment, &first, &second, &curr_idx) == 0)) { + z_bytes_deserialize_into_string(z_loan(first), &kvp->data[kvp->current_idx].key); + z_bytes_deserialize_into_string(z_loan(second), &kvp->data[kvp->current_idx].value); z_bytes_drop(&first); z_bytes_drop(&second); kvp->current_idx++; @@ -110,7 +111,7 @@ void query_handler(const z_loaned_query_t *query, void *ctx) { z_loan(params)->val); // Process value z_owned_string_t payload_string; - z_bytes_decode_into_string(z_value_payload(z_query_value(query)), &payload_string); + z_bytes_deserialize_into_string(z_value_payload(z_query_value(query)), &payload_string); if (z_string_len(z_loan(payload_string)) > 1) { printf(" with value '%s'\n", z_string_data(z_loan(payload_string))); } @@ -134,14 +135,14 @@ void query_handler(const z_loaned_query_t *query, void *ctx) { // Reply value encoding z_owned_bytes_t reply_payload; - z_bytes_encode_from_string(&reply_payload, value); + z_bytes_serialize_from_string(&reply_payload, value); // Reply attachment kv_pair_t kvs[1]; kvs[0] = (kv_pair_t){.key = "reply_key", .value = "reply_value"}; kv_pairs_tx_t kv_ctx = (kv_pairs_tx_t){.data = kvs, .current_idx = 0, .len = 1}; z_owned_bytes_t attachment; - zp_bytes_encode_from_iter(&attachment, create_attachment_iter, (void *)&kv_ctx, kv_pairs_size(&kv_ctx)); + zp_bytes_serialize_from_iter(&attachment, create_attachment_iter, (void *)&kv_ctx, kv_pairs_size(&kv_ctx)); options.attachment = z_move(attachment); z_query_reply(query, z_query_keyexpr(query), z_move(reply_payload), &options); diff --git a/examples/unix/c11/z_queryable_channel.c b/examples/unix/c11/z_queryable_channel.c index 22888c46f..181e32661 100644 --- a/examples/unix/c11/z_queryable_channel.c +++ b/examples/unix/c11/z_queryable_channel.c @@ -108,7 +108,7 @@ int main(int argc, char **argv) { (int)z_loan(params)->len, z_loan(params)->val); // Process value z_owned_string_t payload_string; - z_bytes_decode_into_string(z_value_payload(z_query_value(z_loan(query))), &payload_string); + z_bytes_deserialize_into_string(z_value_payload(z_query_value(z_loan(query))), &payload_string); if (z_string_len(z_loan(payload_string)) > 1) { printf(" with value '%s'\n", z_string_data(z_loan(payload_string))); } @@ -118,7 +118,7 @@ int main(int argc, char **argv) { z_query_reply_options_default(&options); // Reply value encoding z_owned_bytes_t reply_payload; - z_bytes_encode_from_string(&reply_payload, value); + z_bytes_serialize_from_string(&reply_payload, value); z_query_reply(q, z_query_keyexpr(q), z_move(reply_payload), &options); z_drop(z_move(keystr)); diff --git a/examples/unix/c11/z_sub.c b/examples/unix/c11/z_sub.c index a307117d1..f12492c04 100644 --- a/examples/unix/c11/z_sub.c +++ b/examples/unix/c11/z_sub.c @@ -29,7 +29,7 @@ void data_handler(const z_loaned_sample_t *sample, void *ctx) { z_owned_string_t keystr; z_keyexpr_to_string(z_sample_keyexpr(sample), &keystr); z_owned_string_t value; - z_bytes_decode_into_string(z_sample_payload(sample), &value); + z_bytes_deserialize_into_string(z_sample_payload(sample), &value); printf(">> [Subscriber] Received ('%s': '%s')\n", z_string_data(z_loan(keystr)), z_string_data(z_loan(value))); z_drop(z_move(keystr)); z_drop(z_move(value)); diff --git a/examples/unix/c11/z_sub_attachment.c b/examples/unix/c11/z_sub_attachment.c index 7c0a0cfef..32a7c0d0a 100644 --- a/examples/unix/c11/z_sub_attachment.c +++ b/examples/unix/c11/z_sub_attachment.c @@ -40,9 +40,10 @@ static int msg_nb = 0; void parse_attachment(kv_pairs_t *kvp, const z_loaned_bytes_t *attachment) { size_t curr_idx = 0; z_owned_bytes_t first, second; - while ((kvp->current_idx < kvp->len) && (zp_bytes_decode_into_pair(attachment, &first, &second, &curr_idx) == 0)) { - z_bytes_decode_into_string(z_loan(first), &kvp->data[kvp->current_idx].key); - z_bytes_decode_into_string(z_loan(second), &kvp->data[kvp->current_idx].value); + while ((kvp->current_idx < kvp->len) && + (zp_bytes_deserialize_into_pair(attachment, &first, &second, &curr_idx) == 0)) { + z_bytes_deserialize_into_string(z_loan(first), &kvp->data[kvp->current_idx].key); + z_bytes_deserialize_into_string(z_loan(second), &kvp->data[kvp->current_idx].value); z_bytes_drop(&first); z_bytes_drop(&second); kvp->current_idx++; @@ -70,7 +71,7 @@ void data_handler(const z_loaned_sample_t *sample, void *ctx) { z_owned_string_t keystr; z_keyexpr_to_string(z_sample_keyexpr(sample), &keystr); z_owned_string_t value; - z_bytes_decode_into_string(z_sample_payload(sample), &value); + z_bytes_deserialize_into_string(z_sample_payload(sample), &value); printf(">> [Subscriber] Received ('%s': '%s')\n", z_string_data(z_loan(keystr)), z_string_data(z_loan(value))); // Check attachment kv_pairs_t kvp = {.current_idx = 0, .len = KVP_LEN, .data = (kv_pair_t *)malloc(KVP_LEN * sizeof(kv_pair_t))}; diff --git a/examples/unix/c11/z_sub_channel.c b/examples/unix/c11/z_sub_channel.c index 94e341eec..8a00df929 100644 --- a/examples/unix/c11/z_sub_channel.c +++ b/examples/unix/c11/z_sub_channel.c @@ -81,7 +81,7 @@ int main(int argc, char **argv) { z_owned_string_t keystr; z_keyexpr_to_string(z_sample_keyexpr(z_loan(sample)), &keystr); z_owned_string_t value; - z_bytes_decode_into_string(z_sample_payload(z_loan(sample)), &value); + z_bytes_deserialize_into_string(z_sample_payload(z_loan(sample)), &value); printf(">> [Subscriber] Received ('%s': '%s')\n", z_string_data(z_loan(keystr)), z_string_data(z_loan(value))); z_drop(z_move(keystr)); z_drop(z_move(value)); diff --git a/examples/unix/c11/z_sub_st.c b/examples/unix/c11/z_sub_st.c index 004cd1b39..490bf3364 100644 --- a/examples/unix/c11/z_sub_st.c +++ b/examples/unix/c11/z_sub_st.c @@ -28,7 +28,7 @@ void data_handler(const z_loaned_sample_t *sample, void *ctx) { z_owned_string_t keystr; z_keyexpr_to_string(z_sample_keyexpr(sample), &keystr); z_owned_string_t value; - z_bytes_decode_into_string(z_sample_payload(sample), &value); + z_bytes_deserialize_into_string(z_sample_payload(sample), &value); printf(">> [Subscriber] Received ('%s': '%s')\n", z_string_data(z_loan(keystr)), z_string_data(z_loan(value))); z_drop(z_move(keystr)); z_drop(z_move(value)); diff --git a/examples/unix/c99/z_get.c b/examples/unix/c99/z_get.c index e088641ae..ffa687352 100644 --- a/examples/unix/c99/z_get.c +++ b/examples/unix/c99/z_get.c @@ -36,7 +36,7 @@ void reply_handler(const z_loaned_reply_t *reply, void *ctx) { z_owned_string_t keystr; z_keyexpr_to_string(z_sample_keyexpr(sample), &keystr); z_owned_string_t replystr; - z_bytes_decode_into_string(z_sample_payload(sample), &replystr); + z_bytes_deserialize_into_string(z_sample_payload(sample), &replystr); printf(">> Received ('%s': '%s')\n", z_string_data(z_string_loan(&keystr)), z_string_data(z_string_loan(&replystr))); @@ -124,7 +124,7 @@ int main(int argc, char **argv) { // Value encoding z_owned_bytes_t payload; if (value != NULL) { - z_bytes_encode_from_string(&payload, value); + z_bytes_serialize_from_string(&payload, value); opts.payload = &payload; } z_owned_closure_reply_t callback; diff --git a/examples/unix/c99/z_pong.c b/examples/unix/c99/z_pong.c index b40030c9e..f5060147f 100644 --- a/examples/unix/c99/z_pong.c +++ b/examples/unix/c99/z_pong.c @@ -20,7 +20,7 @@ void callback(const z_loaned_sample_t* sample, void* context) { const z_loaned_publisher_t* pub = z_publisher_loan((z_owned_publisher_t*)context); z_owned_slice_t value; - z_bytes_decode_into_slice(z_sample_payload(sample), &value); + z_bytes_deserialize_into_slice(z_sample_payload(sample), &value); z_publisher_put(pub, z_slice_data(z_slice_loan(&value)), z_slice_len(z_slice_loan(&value)), NULL); z_slice_drop(z_slice_move(&value)); } diff --git a/examples/unix/c99/z_queryable.c b/examples/unix/c99/z_queryable.c index b27f792c5..88e2ae92b 100644 --- a/examples/unix/c99/z_queryable.c +++ b/examples/unix/c99/z_queryable.c @@ -32,7 +32,7 @@ void query_handler(const z_loaned_query_t *query, void *ctx) { (int)z_view_string_loan(¶ms)->len, z_view_string_loan(¶ms)->val); // Process value z_owned_string_t payload_string; - z_bytes_decode_into_string(z_value_payload(z_query_value(query)), &payload_string); + z_bytes_deserialize_into_string(z_value_payload(z_query_value(query)), &payload_string); if (z_string_len(z_string_loan(&payload_string)) > 1) { printf(" with value '%s'\n", z_string_data(z_string_loan(&payload_string))); } @@ -47,7 +47,7 @@ void query_handler(const z_loaned_query_t *query, void *ctx) { options.encoding = z_encoding_move(&encoding); // Reply value encoding z_owned_bytes_t reply_payload; - z_bytes_encode_from_string(&reply_payload, value); + z_bytes_serialize_from_string(&reply_payload, value); z_query_reply(query, z_query_keyexpr(query), z_bytes_move(&reply_payload), &options); z_string_drop(z_string_move(&keystr)); diff --git a/examples/unix/c99/z_sub.c b/examples/unix/c99/z_sub.c index f354857aa..92f6716ed 100644 --- a/examples/unix/c99/z_sub.c +++ b/examples/unix/c99/z_sub.c @@ -25,7 +25,7 @@ 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); z_owned_string_t value; - z_bytes_decode_into_string(z_sample_payload(sample), &value); + z_bytes_deserialize_into_string(z_sample_payload(sample), &value); printf(">> [Subscriber] Received ('%s': '%s')\n", z_string_data(z_string_loan(&keystr)), z_string_data(z_string_loan(&value))); z_string_drop(z_string_move(&keystr)); diff --git a/examples/unix/c99/z_sub_st.c b/examples/unix/c99/z_sub_st.c index 548f7a9c6..4c940a4c3 100644 --- a/examples/unix/c99/z_sub_st.c +++ b/examples/unix/c99/z_sub_st.c @@ -28,7 +28,7 @@ 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); z_owned_string_t value; - z_bytes_decode_into_string(z_sample_payload(sample), &value); + z_bytes_deserialize_into_string(z_sample_payload(sample), &value); printf(">> [Subscriber] Received ('%s': '%s')\n", z_string_data(z_string_loan(&keystr)), z_string_data(z_string_loan(&value))); z_string_drop(z_string_move(&keystr)); diff --git a/examples/windows/z_get.c b/examples/windows/z_get.c index a9c06a0bf..a64fba933 100644 --- a/examples/windows/z_get.c +++ b/examples/windows/z_get.c @@ -35,7 +35,7 @@ void reply_handler(const z_loaned_reply_t *reply, void *ctx) { z_owned_string_t keystr; z_keyexpr_to_string(z_sample_keyexpr(sample), &keystr); z_owned_string_t replystr; - z_bytes_decode_into_string(z_sample_payload(sample), &replystr); + z_bytes_deserialize_into_string(z_sample_payload(sample), &replystr); printf(">> Received ('%s': '%s')\n", z_string_data(z_loan(keystr)), z_string_data(z_loan(replystr))); z_drop(z_move(keystr)); @@ -88,7 +88,7 @@ int main(int argc, char **argv) { // Value encoding z_owned_bytes_t payload; if (value != NULL) { - z_bytes_encode_from_string(&payload, value); + z_bytes_serialize_from_string(&payload, value); opts.payload = &payload; } z_owned_closure_reply_t callback; diff --git a/examples/windows/z_pong.c b/examples/windows/z_pong.c index 6b7514bc4..c7e56e5d0 100644 --- a/examples/windows/z_pong.c +++ b/examples/windows/z_pong.c @@ -19,7 +19,7 @@ void callback(const z_loaned_sample_t* sample, void* context) { const z_loaned_publisher_t* pub = z_loan(*(z_owned_publisher_t*)context); z_owned_slice_t value; - z_bytes_decode_into_slice(z_sample_payload(sample), &value); + z_bytes_deserialize_into_slice(z_sample_payload(sample), &value); z_publisher_put(pub, z_slice_data(z_loan(value)), z_slice_len(z_loan(value)), NULL); z_drop(z_move(value)); } diff --git a/examples/windows/z_queryable.c b/examples/windows/z_queryable.c index c87bcd8a3..98d84b108 100644 --- a/examples/windows/z_queryable.c +++ b/examples/windows/z_queryable.c @@ -32,7 +32,7 @@ void query_handler(const z_loaned_query_t *query, void *ctx) { z_loan(params)->val); // Process value z_owned_string_t payload_string; - z_bytes_decode_into_string(z_value_payload(z_query_value(query)), &payload_string); + z_bytes_deserialize_into_string(z_value_payload(z_query_value(query)), &payload_string); if (z_string_len(z_loan(payload_string)) > 1) { printf(" with value '%s'\n", z_string_data(z_loan(payload_string))); } @@ -47,7 +47,7 @@ void query_handler(const z_loaned_query_t *query, void *ctx) { options.encoding = z_move(encoding); // Reply value encoding z_owned_bytes_t reply_payload; - z_bytes_encode_from_string(&reply_payload, value); + z_bytes_serialize_from_string(&reply_payload, value); z_query_reply(query, z_query_keyexpr(query), z_move(reply_payload), &options); diff --git a/examples/windows/z_sub.c b/examples/windows/z_sub.c index 1472a8982..33223375e 100644 --- a/examples/windows/z_sub.c +++ b/examples/windows/z_sub.c @@ -24,7 +24,7 @@ void data_handler(const z_loaned_sample_t *sample, void *ctx) { z_owned_string_t keystr; z_keyexpr_to_string(z_sample_keyexpr(sample), &keystr); z_owned_string_t value; - z_bytes_decode_into_string(z_sample_payload(sample), &value); + z_bytes_deserialize_into_string(z_sample_payload(sample), &value); printf(">> [Subscriber] Received ('%s': '%s')\n", z_string_data(z_loan(keystr)), z_string_data(z_loan(value))); z_drop(z_move(keystr)); z_drop(z_move(value)); diff --git a/examples/windows/z_sub_st.c b/examples/windows/z_sub_st.c index a122b6771..3f09b8dd0 100644 --- a/examples/windows/z_sub_st.c +++ b/examples/windows/z_sub_st.c @@ -27,7 +27,7 @@ void data_handler(const z_loaned_sample_t *sample, void *ctx) { z_owned_string_t keystr; z_keyexpr_to_string(z_sample_keyexpr(sample), &keystr); z_owned_string_t value; - z_bytes_decode_into_string(z_sample_payload(sample), &value); + z_bytes_deserialize_into_string(z_sample_payload(sample), &value); printf(">> [Subscriber] Received ('%s': '%s')\n", z_string_data(z_loan(keystr)), z_string_data(z_loan(value))); z_drop(z_move(keystr)); z_drop(z_move(value)); diff --git a/examples/zephyr/z_get.c b/examples/zephyr/z_get.c index 853d5dfb9..d4d50535b 100644 --- a/examples/zephyr/z_get.c +++ b/examples/zephyr/z_get.c @@ -40,7 +40,7 @@ void reply_handler(const z_loaned_reply_t *oreply, void *ctx) { z_owned_string_t keystr; z_keyexpr_to_string(z_sample_keyexpr(sample), &keystr); z_owned_string_t replystr; - z_bytes_decode_into_string(z_sample_payload(sample), &replystr); + z_bytes_deserialize_into_string(z_sample_payload(sample), &replystr); printf(" >> Received ('%s': '%s')\n", z_string_data(z_loan(keystr)), z_string_data(z_loan(replystr))); z_drop(z_move(keystr)); @@ -83,7 +83,7 @@ int main(int argc, char **argv) { // Value encoding z_owned_bytes_t payload; if (strcmp(VALUE, "") != 0) { - z_bytes_encode_from_string(&payload, VALUE); + z_bytes_serialize_from_string(&payload, VALUE); opts.payload = &payload; } z_owned_closure_reply_t callback; diff --git a/examples/zephyr/z_queryable.c b/examples/zephyr/z_queryable.c index 60a2e0261..679493eb7 100644 --- a/examples/zephyr/z_queryable.c +++ b/examples/zephyr/z_queryable.c @@ -41,7 +41,7 @@ void query_handler(const z_loaned_query_t *query, void *ctx) { z_loan(params)->val); // Process value z_owned_string_t payload_string; - z_bytes_decode_into_string(z_value_payload(z_query_value(query)), &payload_string); + z_bytes_deserialize_into_string(z_value_payload(z_query_value(query)), &payload_string); if (z_string_len(z_loan(payload_string)) > 1) { printf(" with value '%s'\n", z_string_data(z_loan(payload_string))); } @@ -49,7 +49,7 @@ void query_handler(const z_loaned_query_t *query, void *ctx) { // Reply value encoding z_owned_bytes_t reply_payload; - z_bytes_encode_from_string(&reply_payload, VALUE); + z_bytes_serialize_from_string(&reply_payload, VALUE); z_query_reply(query, z_query_keyexpr(query), z_move(reply_payload), NULL); z_drop(z_move(keystr)); diff --git a/examples/zephyr/z_sub.c b/examples/zephyr/z_sub.c index 33e1a8236..df11a93f1 100644 --- a/examples/zephyr/z_sub.c +++ b/examples/zephyr/z_sub.c @@ -33,7 +33,7 @@ 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); z_owned_string_t value; - z_bytes_decode_into_string(z_sample_payload(sample), &value); + z_bytes_deserialize_into_string(z_sample_payload(sample), &value); printf(" >> [Subscriber handler] Received ('%s': '%s')\n", z_string_data(z_loan(keystr)), z_string_data(z_loan(value))); z_drop(z_move(keystr)); diff --git a/include/zenoh-pico/api/primitives.h b/include/zenoh-pico/api/primitives.h index 5ea4f2557..97b1debf4 100644 --- a/include/zenoh-pico/api/primitives.h +++ b/include/zenoh-pico/api/primitives.h @@ -450,7 +450,7 @@ size_t z_slice_len(const z_loaned_slice_t *slice); * Return: * ``0`` if decode successful, or a ``negative value`` otherwise. */ -int8_t z_bytes_decode_into_int8(const z_loaned_bytes_t *bytes, int8_t *dst); +int8_t z_bytes_deserialize_into_int8(const z_loaned_bytes_t *bytes, int8_t *dst); /** * Decodes data into a `int16_t` signed integer. @@ -462,7 +462,7 @@ int8_t z_bytes_decode_into_int8(const z_loaned_bytes_t *bytes, int8_t *dst); * Return: * ``0`` if decode successful, or a ``negative value`` otherwise. */ -int8_t z_bytes_decode_into_int16(const z_loaned_bytes_t *bytes, int16_t *dst); +int8_t z_bytes_deserialize_into_int16(const z_loaned_bytes_t *bytes, int16_t *dst); /** * Decodes data into a `int32_t` signed integer. @@ -474,7 +474,7 @@ int8_t z_bytes_decode_into_int16(const z_loaned_bytes_t *bytes, int16_t *dst); * Return: * ``0`` if decode successful, or a ``negative value`` otherwise. */ -int8_t z_bytes_decode_into_int32(const z_loaned_bytes_t *bytes, int32_t *dst); +int8_t z_bytes_deserialize_into_int32(const z_loaned_bytes_t *bytes, int32_t *dst); /** * Decodes data into a `int64_t` signed integer. @@ -486,7 +486,7 @@ int8_t z_bytes_decode_into_int32(const z_loaned_bytes_t *bytes, int32_t *dst); * Return: * ``0`` if decode successful, or a ``negative value`` otherwise. */ -int8_t z_bytes_decode_into_int64(const z_loaned_bytes_t *bytes, int64_t *dst); +int8_t z_bytes_deserialize_into_int64(const z_loaned_bytes_t *bytes, int64_t *dst); /** * Decodes data into a `uint8_t` unsigned integer. @@ -498,7 +498,7 @@ int8_t z_bytes_decode_into_int64(const z_loaned_bytes_t *bytes, int64_t *dst); * Return: * ``0`` if decode successful, or a ``negative value`` otherwise. */ -int8_t z_bytes_decode_into_uint8(const z_loaned_bytes_t *bytes, uint8_t *dst); +int8_t z_bytes_deserialize_into_uint8(const z_loaned_bytes_t *bytes, uint8_t *dst); /** * Decodes data into a `uint16_t` unsigned integer. @@ -510,7 +510,7 @@ int8_t z_bytes_decode_into_uint8(const z_loaned_bytes_t *bytes, uint8_t *dst); * Return: * ``0`` if decode successful, or a ``negative value`` otherwise. */ -int8_t z_bytes_decode_into_uint16(const z_loaned_bytes_t *bytes, uint16_t *dst); +int8_t z_bytes_deserialize_into_uint16(const z_loaned_bytes_t *bytes, uint16_t *dst); /** * Decodes data into a `uint32_t` unsigned integer. @@ -522,7 +522,7 @@ int8_t z_bytes_decode_into_uint16(const z_loaned_bytes_t *bytes, uint16_t *dst); * Return: * ``0`` if decode successful, or a ``negative value`` otherwise. */ -int8_t z_bytes_decode_into_uint32(const z_loaned_bytes_t *bytes, uint32_t *dst); +int8_t z_bytes_deserialize_into_uint32(const z_loaned_bytes_t *bytes, uint32_t *dst); /** * Decodes data into a `uint64_t` unsigned integer. @@ -534,7 +534,7 @@ int8_t z_bytes_decode_into_uint32(const z_loaned_bytes_t *bytes, uint32_t *dst); * Return: * ``0`` if decode successful, or a ``negative value`` otherwise. */ -int8_t z_bytes_decode_into_uint64(const z_loaned_bytes_t *bytes, uint64_t *dst); +int8_t z_bytes_deserialize_into_uint64(const z_loaned_bytes_t *bytes, uint64_t *dst); /** * Decodes data into a `float` floating number. @@ -546,7 +546,7 @@ int8_t z_bytes_decode_into_uint64(const z_loaned_bytes_t *bytes, uint64_t *dst); * Return: * ``0`` if decode successful, or a ``negative value`` otherwise. */ -int8_t z_bytes_decode_into_float(const z_loaned_bytes_t *bytes, float *dst); +int8_t z_bytes_deserialize_into_float(const z_loaned_bytes_t *bytes, float *dst); /** * Decodes data into a `double` floating number. @@ -558,7 +558,7 @@ int8_t z_bytes_decode_into_float(const z_loaned_bytes_t *bytes, float *dst); * Return: * ``0`` if decode successful, or a ``negative value`` otherwise. */ -int8_t z_bytes_decode_into_double(const z_loaned_bytes_t *bytes, double *dst); +int8_t z_bytes_deserialize_into_double(const z_loaned_bytes_t *bytes, double *dst); /** * Decodes data into a :c:type:`z_owned_slice_t` @@ -570,7 +570,7 @@ int8_t z_bytes_decode_into_double(const z_loaned_bytes_t *bytes, double *dst); * Return: * ``0`` if decode successful, or a ``negative value`` otherwise. */ -int8_t z_bytes_decode_into_slice(const z_loaned_bytes_t *bytes, z_owned_slice_t *dst); +int8_t z_bytes_deserialize_into_slice(const z_loaned_bytes_t *bytes, z_owned_slice_t *dst); /** * Decodes data into a :c:type:`z_owned_string_t` @@ -582,7 +582,7 @@ int8_t z_bytes_decode_into_slice(const z_loaned_bytes_t *bytes, z_owned_slice_t * Return: * ``0`` if decode successful, or a ``negative value`` otherwise. */ -int8_t z_bytes_decode_into_string(const z_loaned_bytes_t *bytes, z_owned_string_t *str); +int8_t z_bytes_deserialize_into_string(const z_loaned_bytes_t *bytes, z_owned_string_t *str); /** * Decodes data into a pair of :c:type:`z_owned_bytes_t` @@ -596,8 +596,8 @@ int8_t z_bytes_decode_into_string(const z_loaned_bytes_t *bytes, z_owned_string_ * Return: * ``0`` if decode successful, or a ``negative value`` otherwise. */ -int8_t zp_bytes_decode_into_pair(const z_loaned_bytes_t *bytes, z_owned_bytes_t *first, z_owned_bytes_t *second, - size_t *curr_idx); +int8_t zp_bytes_deserialize_into_pair(const z_loaned_bytes_t *bytes, z_owned_bytes_t *first, z_owned_bytes_t *second, + size_t *curr_idx); /** * Encodes a signed integer into a :c:type:`z_owned_bytes_t` @@ -609,7 +609,7 @@ int8_t zp_bytes_decode_into_pair(const z_loaned_bytes_t *bytes, z_owned_bytes_t * Return: * ``0`` if encode successful, ``negative value`` otherwise. */ -int8_t z_bytes_encode_from_int8(z_owned_bytes_t *bytes, int8_t val); +int8_t z_bytes_serialize_from_int8(z_owned_bytes_t *bytes, int8_t val); /** * Encodes a signed integer into a :c:type:`z_owned_bytes_t` @@ -621,7 +621,7 @@ int8_t z_bytes_encode_from_int8(z_owned_bytes_t *bytes, int8_t val); * Return: * ``0`` if encode successful, ``negative value`` otherwise. */ -int8_t z_bytes_encode_from_int16(z_owned_bytes_t *bytes, int16_t val); +int8_t z_bytes_serialize_from_int16(z_owned_bytes_t *bytes, int16_t val); /** * Encodes a signed integer into a :c:type:`z_owned_bytes_t` @@ -633,7 +633,7 @@ int8_t z_bytes_encode_from_int16(z_owned_bytes_t *bytes, int16_t val); * Return: * ``0`` if encode successful, ``negative value`` otherwise. */ -int8_t z_bytes_encode_from_int32(z_owned_bytes_t *bytes, int32_t val); +int8_t z_bytes_serialize_from_int32(z_owned_bytes_t *bytes, int32_t val); /** * Encodes a signed integer into a :c:type:`z_owned_bytes_t` @@ -645,7 +645,7 @@ int8_t z_bytes_encode_from_int32(z_owned_bytes_t *bytes, int32_t val); * Return: * ``0`` if encode successful, ``negative value`` otherwise. */ -int8_t z_bytes_encode_from_int64(z_owned_bytes_t *bytes, int64_t val); +int8_t z_bytes_serialize_from_int64(z_owned_bytes_t *bytes, int64_t val); /** * Encodes an unsigned integer into a :c:type:`z_owned_bytes_t` @@ -657,7 +657,7 @@ int8_t z_bytes_encode_from_int64(z_owned_bytes_t *bytes, int64_t val); * Return: * ``0`` if encode successful, ``negative value`` otherwise. */ -int8_t z_bytes_encode_from_uint8(z_owned_bytes_t *bytes, uint8_t val); +int8_t z_bytes_serialize_from_uint8(z_owned_bytes_t *bytes, uint8_t val); /** * Encodes an unsigned integer into a :c:type:`z_owned_bytes_t` @@ -669,7 +669,7 @@ int8_t z_bytes_encode_from_uint8(z_owned_bytes_t *bytes, uint8_t val); * Return: * ``0`` if encode successful, ``negative value`` otherwise. */ -int8_t z_bytes_encode_from_uint16(z_owned_bytes_t *bytes, uint16_t val); +int8_t z_bytes_serialize_from_uint16(z_owned_bytes_t *bytes, uint16_t val); /** * Encodes an unsigned integer into a :c:type:`z_owned_bytes_t` @@ -681,7 +681,7 @@ int8_t z_bytes_encode_from_uint16(z_owned_bytes_t *bytes, uint16_t val); * Return: * ``0`` if encode successful, ``negative value`` otherwise. */ -int8_t z_bytes_encode_from_uint32(z_owned_bytes_t *bytes, uint32_t val); +int8_t z_bytes_serialize_from_uint32(z_owned_bytes_t *bytes, uint32_t val); /** * Encodes an unsigned integer into a :c:type:`z_owned_bytes_t` @@ -693,7 +693,7 @@ int8_t z_bytes_encode_from_uint32(z_owned_bytes_t *bytes, uint32_t val); * Return: * ``0`` if encode successful, ``negative value`` otherwise. */ -int8_t z_bytes_encode_from_uint64(z_owned_bytes_t *bytes, uint64_t val); +int8_t z_bytes_serialize_from_uint64(z_owned_bytes_t *bytes, uint64_t val); /** * Encodes a floating number into a :c:type:`z_owned_bytes_t` @@ -705,7 +705,7 @@ int8_t z_bytes_encode_from_uint64(z_owned_bytes_t *bytes, uint64_t val); * Return: * ``0`` if encode successful, ``negative value`` otherwise. */ -int8_t z_bytes_encode_from_float(z_owned_bytes_t *bytes, float val); +int8_t z_bytes_serialize_from_float(z_owned_bytes_t *bytes, float val); /** * Encodes a floating number into a :c:type:`z_owned_bytes_t` @@ -717,7 +717,7 @@ int8_t z_bytes_encode_from_float(z_owned_bytes_t *bytes, float val); * Return: * ``0`` if encode successful, ``negative value`` otherwise. */ -int8_t z_bytes_encode_from_double(z_owned_bytes_t *bytes, double val); +int8_t z_bytes_serialize_from_double(z_owned_bytes_t *bytes, double val); /** * Encodes a slice into a :c:type:`z_owned_bytes_t` by aliasing @@ -729,7 +729,7 @@ int8_t z_bytes_encode_from_double(z_owned_bytes_t *bytes, double val); * Return: * ``0`` if encode successful, ``negative value`` otherwise. */ -int8_t z_bytes_encode_from_slice(z_owned_bytes_t *bytes, const uint8_t *data, size_t len); +int8_t z_bytes_serialize_from_slice(z_owned_bytes_t *bytes, const uint8_t *data, size_t len); /** * Encodes a slice into a :c:type:`z_owned_bytes_t` by copying @@ -741,7 +741,7 @@ int8_t z_bytes_encode_from_slice(z_owned_bytes_t *bytes, const uint8_t *data, si * Return: * ``0`` if encode successful, ``negative value`` otherwise. */ -int8_t z_bytes_encode_from_slice_copy(z_owned_bytes_t *bytes, const uint8_t *data, size_t len); +int8_t z_bytes_serialize_from_slice_copy(z_owned_bytes_t *bytes, const uint8_t *data, size_t len); /** * Encodes a string into a :c:type:`z_owned_bytes_t` by aliasing @@ -753,7 +753,7 @@ int8_t z_bytes_encode_from_slice_copy(z_owned_bytes_t *bytes, const uint8_t *dat * Return: * ``0`` if encode successful, ``negative value`` otherwise. */ -int8_t z_bytes_encode_from_string(z_owned_bytes_t *bytes, const char *s); +int8_t z_bytes_serialize_from_string(z_owned_bytes_t *bytes, const char *s); /** * Encodes a string into a :c:type:`z_owned_bytes_t` by copying @@ -765,7 +765,7 @@ int8_t z_bytes_encode_from_string(z_owned_bytes_t *bytes, const char *s); * Return: * ``0`` if encode successful, ``negative value`` otherwise. */ -int8_t z_bytes_encode_from_string_copy(z_owned_bytes_t *bytes, const char *s); +int8_t z_bytes_serialize_from_string_copy(z_owned_bytes_t *bytes, const char *s); /** * Constructs payload from an iterator to `z_owned_bytes_t`. @@ -778,9 +778,9 @@ int8_t z_bytes_encode_from_string_copy(z_owned_bytes_t *bytes, const char *s); * Return: * ``0`` if encode successful, ``negative value`` otherwise. */ -int8_t zp_bytes_encode_from_iter(z_owned_bytes_t *bytes, - _Bool (*iterator_body)(z_owned_bytes_t *data, void *context, size_t *curr_idx), - void *context, size_t total_len); +int8_t zp_bytes_serialize_from_iter(z_owned_bytes_t *bytes, + _Bool (*iterator_body)(z_owned_bytes_t *data, void *context, size_t *curr_idx), + void *context, size_t total_len); /** * Append a pair of `z_owned_bytes` objects which are consumed in the process. @@ -794,8 +794,8 @@ int8_t zp_bytes_encode_from_iter(z_owned_bytes_t *bytes, * Return: * ``0`` if encode successful, ``negative value`` otherwise. */ -int8_t zp_bytes_encode_from_pair(z_owned_bytes_t *bytes, z_owned_bytes_t *first, z_owned_bytes_t *second, - size_t *curr_idx); +int8_t zp_bytes_serialize_from_pair(z_owned_bytes_t *bytes, z_owned_bytes_t *first, z_owned_bytes_t *second, + size_t *curr_idx); /** * Checks validity of a timestamp diff --git a/src/api/api.c b/src/api/api.c index c1baf064b..1072c95b9 100644 --- a/src/api/api.c +++ b/src/api/api.c @@ -263,57 +263,57 @@ const uint8_t *z_slice_data(const z_loaned_slice_t *slice) { return slice->start size_t z_slice_len(const z_loaned_slice_t *slice) { return slice->len; } -int8_t z_bytes_decode_into_int8(const z_loaned_bytes_t *bytes, int8_t *dst) { +int8_t z_bytes_deserialize_into_int8(const z_loaned_bytes_t *bytes, int8_t *dst) { *dst = (int8_t)_z_bytes_to_uint8(bytes); return _Z_RES_OK; } -int8_t z_bytes_decode_into_int16(const z_loaned_bytes_t *bytes, int16_t *dst) { +int8_t z_bytes_deserialize_into_int16(const z_loaned_bytes_t *bytes, int16_t *dst) { *dst = (int16_t)_z_bytes_to_uint16(bytes); return _Z_RES_OK; } -int8_t z_bytes_decode_into_int32(const z_loaned_bytes_t *bytes, int32_t *dst) { +int8_t z_bytes_deserialize_into_int32(const z_loaned_bytes_t *bytes, int32_t *dst) { *dst = (int32_t)_z_bytes_to_uint32(bytes); return _Z_RES_OK; } -int8_t z_bytes_decode_into_int64(const z_loaned_bytes_t *bytes, int64_t *dst) { +int8_t z_bytes_deserialize_into_int64(const z_loaned_bytes_t *bytes, int64_t *dst) { *dst = (int64_t)_z_bytes_to_uint64(bytes); return _Z_RES_OK; } -int8_t z_bytes_decode_into_uint8(const z_loaned_bytes_t *bytes, uint8_t *dst) { +int8_t z_bytes_deserialize_into_uint8(const z_loaned_bytes_t *bytes, uint8_t *dst) { *dst = _z_bytes_to_uint8(bytes); return _Z_RES_OK; } -int8_t z_bytes_decode_into_uint16(const z_loaned_bytes_t *bytes, uint16_t *dst) { +int8_t z_bytes_deserialize_into_uint16(const z_loaned_bytes_t *bytes, uint16_t *dst) { *dst = _z_bytes_to_uint16(bytes); return _Z_RES_OK; } -int8_t z_bytes_decode_into_uint32(const z_loaned_bytes_t *bytes, uint32_t *dst) { +int8_t z_bytes_deserialize_into_uint32(const z_loaned_bytes_t *bytes, uint32_t *dst) { *dst = _z_bytes_to_uint32(bytes); return _Z_RES_OK; } -int8_t z_bytes_decode_into_uint64(const z_loaned_bytes_t *bytes, uint64_t *dst) { +int8_t z_bytes_deserialize_into_uint64(const z_loaned_bytes_t *bytes, uint64_t *dst) { *dst = _z_bytes_to_uint64(bytes); return _Z_RES_OK; } -int8_t z_bytes_decode_into_float(const z_loaned_bytes_t *bytes, float *dst) { +int8_t z_bytes_deserialize_into_float(const z_loaned_bytes_t *bytes, float *dst) { *dst = _z_bytes_to_float(bytes); return _Z_RES_OK; } -int8_t z_bytes_decode_into_double(const z_loaned_bytes_t *bytes, double *dst) { +int8_t z_bytes_deserialize_into_double(const z_loaned_bytes_t *bytes, double *dst) { *dst = _z_bytes_to_double(bytes); return _Z_RES_OK; } -int8_t z_bytes_decode_into_slice(const z_loaned_bytes_t *bytes, z_owned_slice_t *dst) { +int8_t z_bytes_deserialize_into_slice(const z_loaned_bytes_t *bytes, z_owned_slice_t *dst) { // Init owned slice z_slice_null(dst); dst->_val = (_z_slice_t *)z_malloc(sizeof(_z_slice_t)); @@ -325,7 +325,7 @@ int8_t z_bytes_decode_into_slice(const z_loaned_bytes_t *bytes, z_owned_slice_t return _Z_RES_OK; } -int8_t z_bytes_decode_into_string(const z_loaned_bytes_t *bytes, z_owned_string_t *s) { +int8_t z_bytes_deserialize_into_string(const z_loaned_bytes_t *bytes, z_owned_string_t *s) { // Init owned string z_string_null(s); s->_val = (_z_string_t *)z_malloc(sizeof(_z_string_t)); @@ -337,8 +337,8 @@ int8_t z_bytes_decode_into_string(const z_loaned_bytes_t *bytes, z_owned_string_ return _Z_RES_OK; } -int8_t zp_bytes_decode_into_pair(const z_loaned_bytes_t *bytes, z_owned_bytes_t *first, z_owned_bytes_t *second, - size_t *curr_idx) { +int8_t zp_bytes_deserialize_into_pair(const z_loaned_bytes_t *bytes, z_owned_bytes_t *first, z_owned_bytes_t *second, + size_t *curr_idx) { // Check bound size if (*curr_idx >= bytes->_slice.len) { return _Z_ERR_GENERIC; @@ -380,23 +380,23 @@ int8_t zp_bytes_decode_into_pair(const z_loaned_bytes_t *bytes, z_owned_bytes_t return _Z_RES_OK; } -int8_t z_bytes_encode_from_int8(z_owned_bytes_t *bytes, int8_t val) { - return z_bytes_encode_from_uint8(bytes, (uint8_t)val); +int8_t z_bytes_serialize_from_int8(z_owned_bytes_t *bytes, int8_t val) { + return z_bytes_serialize_from_uint8(bytes, (uint8_t)val); } -int8_t z_bytes_encode_from_int16(z_owned_bytes_t *bytes, int16_t val) { - return z_bytes_encode_from_uint16(bytes, (uint16_t)val); +int8_t z_bytes_serialize_from_int16(z_owned_bytes_t *bytes, int16_t val) { + return z_bytes_serialize_from_uint16(bytes, (uint16_t)val); } -int8_t z_bytes_encode_from_int32(z_owned_bytes_t *bytes, int32_t val) { - return z_bytes_encode_from_uint32(bytes, (uint32_t)val); +int8_t z_bytes_serialize_from_int32(z_owned_bytes_t *bytes, int32_t val) { + return z_bytes_serialize_from_uint32(bytes, (uint32_t)val); } -int8_t z_bytes_encode_from_int64(z_owned_bytes_t *bytes, int64_t val) { - return z_bytes_encode_from_uint64(bytes, (uint64_t)val); +int8_t z_bytes_serialize_from_int64(z_owned_bytes_t *bytes, int64_t val) { + return z_bytes_serialize_from_uint64(bytes, (uint64_t)val); } -int8_t z_bytes_encode_from_uint8(z_owned_bytes_t *bytes, uint8_t val) { +int8_t z_bytes_serialize_from_uint8(z_owned_bytes_t *bytes, uint8_t val) { // Init owned bytes z_bytes_null(bytes); bytes->_val = (_z_bytes_t *)z_malloc(sizeof(_z_bytes_t)); @@ -411,7 +411,7 @@ int8_t z_bytes_encode_from_uint8(z_owned_bytes_t *bytes, uint8_t val) { return _Z_RES_OK; } -int8_t z_bytes_encode_from_uint16(z_owned_bytes_t *bytes, uint16_t val) { +int8_t z_bytes_serialize_from_uint16(z_owned_bytes_t *bytes, uint16_t val) { // Init owned bytes z_bytes_null(bytes); bytes->_val = (_z_bytes_t *)z_malloc(sizeof(_z_bytes_t)); @@ -426,7 +426,7 @@ int8_t z_bytes_encode_from_uint16(z_owned_bytes_t *bytes, uint16_t val) { return _Z_RES_OK; } -int8_t z_bytes_encode_from_uint32(z_owned_bytes_t *bytes, uint32_t val) { +int8_t z_bytes_serialize_from_uint32(z_owned_bytes_t *bytes, uint32_t val) { // Init owned bytes z_bytes_null(bytes); bytes->_val = (_z_bytes_t *)z_malloc(sizeof(_z_bytes_t)); @@ -441,7 +441,7 @@ int8_t z_bytes_encode_from_uint32(z_owned_bytes_t *bytes, uint32_t val) { return _Z_RES_OK; } -int8_t z_bytes_encode_from_uint64(z_owned_bytes_t *bytes, uint64_t val) { +int8_t z_bytes_serialize_from_uint64(z_owned_bytes_t *bytes, uint64_t val) { // Init owned bytes z_bytes_null(bytes); bytes->_val = (_z_bytes_t *)z_malloc(sizeof(_z_bytes_t)); @@ -456,7 +456,7 @@ int8_t z_bytes_encode_from_uint64(z_owned_bytes_t *bytes, uint64_t val) { return _Z_RES_OK; } -int8_t z_bytes_encode_from_float(z_owned_bytes_t *bytes, float val) { +int8_t z_bytes_serialize_from_float(z_owned_bytes_t *bytes, float val) { // Init owned bytes z_bytes_null(bytes); bytes->_val = (_z_bytes_t *)z_malloc(sizeof(_z_bytes_t)); @@ -471,7 +471,7 @@ int8_t z_bytes_encode_from_float(z_owned_bytes_t *bytes, float val) { return _Z_RES_OK; } -int8_t z_bytes_encode_from_double(z_owned_bytes_t *bytes, double val) { +int8_t z_bytes_serialize_from_double(z_owned_bytes_t *bytes, double val) { // Init owned bytes z_bytes_null(bytes); bytes->_val = (_z_bytes_t *)z_malloc(sizeof(_z_bytes_t)); @@ -486,7 +486,7 @@ int8_t z_bytes_encode_from_double(z_owned_bytes_t *bytes, double val) { return _Z_RES_OK; } -int8_t z_bytes_encode_from_slice(z_owned_bytes_t *bytes, const uint8_t *data, size_t len) { +int8_t z_bytes_serialize_from_slice(z_owned_bytes_t *bytes, const uint8_t *data, size_t len) { // Init owned bytes z_bytes_null(bytes); bytes->_val = (_z_bytes_t *)z_malloc(sizeof(_z_bytes_t)); @@ -498,7 +498,7 @@ int8_t z_bytes_encode_from_slice(z_owned_bytes_t *bytes, const uint8_t *data, si return _Z_RES_OK; } -int8_t z_bytes_encode_from_slice_copy(z_owned_bytes_t *bytes, const uint8_t *data, size_t len) { +int8_t z_bytes_serialize_from_slice_copy(z_owned_bytes_t *bytes, const uint8_t *data, size_t len) { // Init owned bytes z_bytes_null(bytes); bytes->_val = (_z_bytes_t *)z_malloc(sizeof(_z_bytes_t)); @@ -515,7 +515,7 @@ int8_t z_bytes_encode_from_slice_copy(z_owned_bytes_t *bytes, const uint8_t *dat return _Z_RES_OK; } -int8_t z_bytes_encode_from_string(z_owned_bytes_t *bytes, const char *s) { +int8_t z_bytes_serialize_from_string(z_owned_bytes_t *bytes, const char *s) { // Init owned bytes z_bytes_null(bytes); bytes->_val = (_z_bytes_t *)z_malloc(sizeof(_z_bytes_t)); @@ -528,7 +528,7 @@ int8_t z_bytes_encode_from_string(z_owned_bytes_t *bytes, const char *s) { return _Z_RES_OK; } -int8_t z_bytes_encode_from_string_copy(z_owned_bytes_t *bytes, const char *s) { +int8_t z_bytes_serialize_from_string_copy(z_owned_bytes_t *bytes, const char *s) { // Init owned bytes z_bytes_null(bytes); bytes->_val = (_z_bytes_t *)z_malloc(sizeof(_z_bytes_t)); @@ -546,9 +546,9 @@ int8_t z_bytes_encode_from_string_copy(z_owned_bytes_t *bytes, const char *s) { return _Z_RES_OK; } -int8_t zp_bytes_encode_from_iter(z_owned_bytes_t *bytes, - _Bool (*iterator_body)(z_owned_bytes_t *data, void *context, size_t *curr_idx), - void *context, size_t total_len) { +int8_t zp_bytes_serialize_from_iter(z_owned_bytes_t *bytes, + _Bool (*iterator_body)(z_owned_bytes_t *data, void *context, size_t *curr_idx), + void *context, size_t total_len) { // Init owned bytes z_bytes_null(bytes); bytes->_val = (_z_bytes_t *)z_malloc(sizeof(_z_bytes_t)); @@ -566,8 +566,8 @@ int8_t zp_bytes_encode_from_iter(z_owned_bytes_t *bytes, return _Z_RES_OK; } -int8_t zp_bytes_encode_from_pair(z_owned_bytes_t *bytes, z_owned_bytes_t *first, z_owned_bytes_t *second, - size_t *curr_idx) { +int8_t zp_bytes_serialize_from_pair(z_owned_bytes_t *bytes, z_owned_bytes_t *first, z_owned_bytes_t *second, + size_t *curr_idx) { // Calculate pair size size_t first_len = z_slice_len(&first->_val->_slice); size_t second_len = z_slice_len(&second->_val->_slice); diff --git a/tests/z_api_alignment_test.c b/tests/z_api_alignment_test.c index 9c7a36939..c63dce561 100644 --- a/tests/z_api_alignment_test.c +++ b/tests/z_api_alignment_test.c @@ -84,7 +84,7 @@ void query_handler(const z_loaned_query_t *query, void *arg) { // Reply value encoding z_owned_bytes_t reply_payload; - z_bytes_encode_from_string(&reply_payload, value); + z_bytes_serialize_from_string(&reply_payload, value); z_query_reply(query, query_ke, z_move(reply_payload), &_ret_qreply_opt); diff --git a/tests/z_channels_test.c b/tests/z_channels_test.c index da794fd9f..b9954cdcb 100644 --- a/tests/z_channels_test.c +++ b/tests/z_channels_test.c @@ -35,22 +35,22 @@ z_call(channel.send, &sample); \ } while (0); -#define _RECV(channel, method, buf) \ - do { \ - z_owned_sample_t sample; \ - z_sample_null(&sample); \ - z_call(channel.method, &sample); \ - if (z_check(sample)) { \ - z_owned_slice_t value; \ - z_bytes_decode_into_slice(z_sample_payload(z_loan(sample)), &value); \ - size_t value_len = z_slice_len(z_loan(value)); \ - strncpy(buf, (const char *)z_slice_data(z_loan(value)), value_len); \ - buf[value_len] = '\0'; \ - z_drop(z_move(sample)); \ - z_drop(z_move(value)); \ - } else { \ - buf[0] = '\0'; \ - } \ +#define _RECV(channel, method, buf) \ + do { \ + z_owned_sample_t sample; \ + z_sample_null(&sample); \ + z_call(channel.method, &sample); \ + if (z_check(sample)) { \ + z_owned_slice_t value; \ + z_bytes_deserialize_into_slice(z_sample_payload(z_loan(sample)), &value); \ + size_t value_len = z_slice_len(z_loan(value)); \ + strncpy(buf, (const char *)z_slice_data(z_loan(value)), value_len); \ + buf[value_len] = '\0'; \ + z_drop(z_move(sample)); \ + z_drop(z_move(value)); \ + } else { \ + buf[0] = '\0'; \ + } \ } while (0); #define RECV(channel, buf) _RECV(channel, recv, buf) diff --git a/tests/z_client_test.c b/tests/z_client_test.c index c82bd25c4..4a8813e3d 100644 --- a/tests/z_client_test.c +++ b/tests/z_client_test.c @@ -63,7 +63,7 @@ void query_handler(const z_loaned_query_t *query, void *arg) { // Reply value encoding z_owned_bytes_t reply_payload; - z_bytes_encode_from_string(&reply_payload, res); + z_bytes_serialize_from_string(&reply_payload, res); z_query_reply(query, z_query_keyexpr(query), z_move(reply_payload), NULL); queries++; @@ -82,7 +82,7 @@ void reply_handler(const z_loaned_reply_t *reply, void *arg) { z_owned_string_t k_str; z_keyexpr_to_string(z_sample_keyexpr(sample), &k_str); z_owned_string_t value; - z_bytes_decode_into_string(z_sample_payload(sample), &value); + z_bytes_deserialize_into_string(z_sample_payload(sample), &value); assert(z_string_len(z_loan(value)) == strlen(res) + 1); assert(strncmp(res, z_string_data(z_loan(value)), strlen(res)) == 0); assert(_z_str_eq(z_loan(k_str)->val, res) == true); @@ -105,7 +105,7 @@ void data_handler(const z_loaned_sample_t *sample, void *arg) { z_owned_string_t k_str; z_keyexpr_to_string(z_sample_keyexpr(sample), &k_str); z_owned_slice_t value; - z_bytes_decode_into_slice(z_sample_payload(sample), &value); + z_bytes_deserialize_into_slice(z_sample_payload(sample), &value); size_t payload_len = z_slice_len(z_loan(value)); assert((payload_len == MSG_LEN) || (payload_len == FRAGMENT_MSG_LEN)); assert(_z_str_eq(z_loan(k_str)->val, res) == true); diff --git a/tests/z_peer_multicast_test.c b/tests/z_peer_multicast_test.c index 93a17c10a..7413cfb0d 100644 --- a/tests/z_peer_multicast_test.c +++ b/tests/z_peer_multicast_test.c @@ -49,7 +49,7 @@ void data_handler(const z_loaned_sample_t *sample, void *arg) { z_owned_string_t k_str; z_keyexpr_to_string(z_sample_keyexpr(sample), &k_str); z_owned_slice_t value; - z_bytes_decode_into_slice(z_sample_payload(sample), &value); + z_bytes_deserialize_into_slice(z_sample_payload(sample), &value); assert(z_slice_len(z_loan(value)) == MSG_LEN); assert(z_loan(k_str)->len == strlen(res)); assert(strncmp(res, z_loan(k_str)->val, strlen(res)) == 0); diff --git a/tests/z_perf_rx.c b/tests/z_perf_rx.c index 65511a4b4..e97fff1b0 100644 --- a/tests/z_perf_rx.c +++ b/tests/z_perf_rx.c @@ -42,7 +42,7 @@ void z_stats_stop(z_stats_t *stats) { void on_sample(const z_loaned_sample_t *sample, void *context) { z_stats_t *stats = (z_stats_t *)context; z_owned_slice_t value; - z_bytes_decode_into_slice(z_sample_payload(sample), &value); + z_bytes_deserialize_into_slice(z_sample_payload(sample), &value); unsigned long data_len = (unsigned long)z_slice_len(z_loan(value)); if (stats->curr_len != data_len) { diff --git a/tests/z_test_fragment_rx.c b/tests/z_test_fragment_rx.c index 06fafd4ae..155e2894c 100644 --- a/tests/z_test_fragment_rx.c +++ b/tests/z_test_fragment_rx.c @@ -24,7 +24,7 @@ void data_handler(const z_loaned_sample_t *sample, void *ctx) { z_keyexpr_to_string(z_sample_keyexpr(sample), &keystr); bool is_valid = true; z_owned_slice_t value; - z_bytes_decode_into_slice(z_sample_payload(sample), &value); + z_bytes_deserialize_into_slice(z_sample_payload(sample), &value); const uint8_t *data = z_slice_data(z_loan(value)); size_t data_len = z_slice_len(z_loan(value)); for (size_t i = 0; i < data_len; i++) {