Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rename (de/en)code to (de)serialize #461

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
66 changes: 33 additions & 33 deletions docs/api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -132,39 +132,39 @@ Types
Functions
^^^^^^^^^
.. doxygenfunction:: z_bytes_len
.. doxygenfunction:: z_bytes_encode_from_slice
.. doxygenfunction:: z_bytes_encode_from_string
.. doxygenfunction:: z_bytes_encode_from_slice_map
.. doxygenfunction:: z_bytes_encode_from_iter
.. doxygenfunction:: z_bytes_encode_from_pair

.. doxygenfunction:: z_bytes_encode_from_uint8
.. doxygenfunction:: z_bytes_encode_from_uint16
.. doxygenfunction:: z_bytes_encode_from_uint32
.. doxygenfunction:: z_bytes_encode_from_uint64
.. doxygenfunction:: z_bytes_encode_from_int8
.. doxygenfunction:: z_bytes_encode_from_int16
.. doxygenfunction:: z_bytes_encode_from_int32
.. doxygenfunction:: z_bytes_encode_from_int64
.. doxygenfunction:: z_bytes_encode_from_float
.. doxygenfunction:: z_bytes_encode_from_double

.. doxygenfunction:: z_bytes_decode_into_slice
.. doxygenfunction:: z_bytes_decode_into_string
.. doxygenfunction:: z_bytes_decode_into_slice_map
.. doxygenfunction:: z_bytes_decode_into_iter
.. doxygenfunction:: z_bytes_decode_into_pair

.. doxygenfunction:: z_bytes_decode_into_uint8
.. doxygenfunction:: z_bytes_decode_into_uint16
.. doxygenfunction:: z_bytes_decode_into_uint32
.. doxygenfunction:: z_bytes_decode_into_uint64
.. doxygenfunction:: z_bytes_decode_into_int8
.. doxygenfunction:: z_bytes_decode_into_int16
.. doxygenfunction:: z_bytes_decode_into_int32
.. doxygenfunction:: z_bytes_decode_into_int64
.. doxygenfunction:: z_bytes_decode_into_float
.. doxygenfunction:: z_bytes_decode_into_double
.. doxygenfunction:: z_bytes_serialize_from_slice
.. doxygenfunction:: z_bytes_serialize_from_string
.. doxygenfunction:: z_bytes_serialize_from_slice_map
.. doxygenfunction:: z_bytes_serialize_from_iter
.. doxygenfunction:: z_bytes_serialize_from_pair

.. doxygenfunction:: z_bytes_serialize_from_uint8
.. doxygenfunction:: z_bytes_serialize_from_uint16
.. doxygenfunction:: z_bytes_serialize_from_uint32
.. doxygenfunction:: z_bytes_serialize_from_uint64
.. doxygenfunction:: z_bytes_serialize_from_int8
.. doxygenfunction:: z_bytes_serialize_from_int16
.. doxygenfunction:: z_bytes_serialize_from_int32
.. doxygenfunction:: z_bytes_serialize_from_int64
.. doxygenfunction:: z_bytes_serialize_from_float
.. doxygenfunction:: z_bytes_serialize_from_double

.. doxygenfunction:: z_bytes_deserialize_into_slice
.. doxygenfunction:: z_bytes_deserialize_into_string
.. doxygenfunction:: z_bytes_deserialize_into_slice_map
.. doxygenfunction:: z_bytes_deserialize_into_iter
.. doxygenfunction:: z_bytes_deserialize_into_pair

.. doxygenfunction:: z_bytes_deserialize_into_uint8
.. doxygenfunction:: z_bytes_deserialize_into_uint16
.. doxygenfunction:: z_bytes_deserialize_into_uint32
.. doxygenfunction:: z_bytes_deserialize_into_uint64
.. doxygenfunction:: z_bytes_deserialize_into_int8
.. doxygenfunction:: z_bytes_deserialize_into_int16
.. doxygenfunction:: z_bytes_deserialize_into_int32
.. doxygenfunction:: z_bytes_deserialize_into_int64
.. doxygenfunction:: z_bytes_deserialize_into_float
.. doxygenfunction:: z_bytes_deserialize_into_double

.. doxygenfunction:: z_bytes_empty
.. doxygenfunction:: z_bytes_clone
Expand Down
10 changes: 5 additions & 5 deletions docs/examples.rst
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ Publish
}

z_owned_bytes_t payload;
z_bytes_encode_from_string(&payload, "value");
z_bytes_serialize_from_string(&payload, "value");
z_view_keyexpr_t key_expr;
z_view_keyexpr_from_string(&key_expr, "key/expression");

Expand All @@ -56,7 +56,7 @@ Subscribe
z_view_string_t key_string;
z_keyexpr_to_string(z_sample_keyexpr(sample), &key_string);
z_owned_string_t payload_string;
z_bytes_decode_into_string(z_sample_payload(sample), &payload_string);
z_bytes_deserialize_into_string(z_sample_payload(sample), &payload_string);
printf(">> Received (%.*s, %.*s)\n",
(int)z_str_len(z_loan(key_string)), z_str_data(z_loan(key_string)),
(int)z_str_len(z_loan(payload_string)), z_str_data(z_loan(payload_string))
Expand Down Expand Up @@ -129,7 +129,7 @@ Query
z_view_string_t key_string;
z_keyexpr_to_string(z_sample_keyexpr(sample), &key_string);
z_owned_string_t payload_string;
z_bytes_decode_into_string(z_sample_payload(sample), &payload_string);
z_bytes_deserialize_into_string(z_sample_payload(sample), &payload_string);
printf(">> Received (%.*s, %.*s)\n",
(int)z_str_len(z_loan(key_string)), z_str_data(z_loan(key_string)),
(int)z_str_len(z_loan(payload_string)), z_str_data(z_loan(payload_string))
Expand Down Expand Up @@ -160,7 +160,7 @@ Queryable
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);
z_bytes_deserialize_into_string(payload, &payload_string);

printf(">> [Queryable ] Received Query '%.*s' with value '%.*s'\n",
(int)z_str_len(z_loan(key_string)), z_str_data(z_loan(key_string)),
Expand All @@ -171,7 +171,7 @@ Queryable
}

z_owned_bytes_t reply_payload;
z_bytes_encode_from_string(&reply_payload, "reply");
z_bytes_serialize_from_string(&reply_payload, "reply");

z_view_keyexpr_t reply_keyexpr;
z_view_keyexpr_from_string(&reply_keyexpr, (const char *)context);
Expand Down
4 changes: 2 additions & 2 deletions examples/z_get.c
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ int main(int argc, char **argv) {

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_get(z_loan(s), z_loan(keyexpr), "", z_move(closure),
Expand All @@ -79,7 +79,7 @@ int main(int argc, char **argv) {
z_keyexpr_as_view_string(z_sample_keyexpr(sample), &key_str);

z_owned_string_t reply_str;
z_bytes_decode_into_string(z_sample_payload(sample), &reply_str);
z_bytes_deserialize_into_string(z_sample_payload(sample), &reply_str);

printf(">> Received ('%.*s': '%.*s')\n", (int)z_string_len(z_loan(key_str)), z_string_data(z_loan(key_str)),
(int)z_string_len(z_loan(reply_str)), z_string_data(z_loan(reply_str)));
Expand Down
4 changes: 2 additions & 2 deletions examples/z_get_shm.c
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ int main(int argc, char** argv) {

z_owned_bytes_t payload;
if (value != NULL) {
z_bytes_encode_from_shm_copy(&payload, z_loan(shm));
z_bytes_serialize_from_shm_copy(&payload, z_loan(shm));
opts.payload = &payload;
}
z_get(z_loan(s), z_loan(keyexpr), "", z_move(closure),
Expand All @@ -106,7 +106,7 @@ int main(int argc, char** argv) {
z_keyexpr_as_view_string(z_sample_keyexpr(sample), &key_str);

z_owned_string_t reply_str;
z_bytes_decode_into_string(z_sample_payload(sample), &reply_str);
z_bytes_deserialize_into_string(z_sample_payload(sample), &reply_str);

printf(">> Received ('%.*s': '%.*s')\n", (int)z_string_len(z_loan(key_str)), z_string_data(z_loan(key_str)),
(int)z_string_len(z_loan(reply_str)), z_string_data(z_loan(reply_str)));
Expand Down
2 changes: 1 addition & 1 deletion examples/z_non_blocking_get.c
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ int main(int argc, char **argv) {
z_view_string_t key_str;
z_owned_string_t payload_string;
z_keyexpr_as_view_string(z_sample_keyexpr(sample), &key_str);
z_bytes_decode_into_string(z_sample_payload(sample), &payload_string);
z_bytes_deserialize_into_string(z_sample_payload(sample), &payload_string);
printf(">> Received ('%.*s': '%.*s')\n", (int)z_string_len(z_loan(key_str)), z_string_data(z_loan(key_str)),
(int)z_string_len(z_loan(payload_string)), z_string_data(z_loan(payload_string)));
z_drop(z_move(payload_string));
Expand Down
4 changes: 2 additions & 2 deletions examples/z_ping.c
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ int main(int argc, char** argv) {

unsigned long elapsed_us = 0;
while (elapsed_us < args.warmup_ms * 1000) {
z_bytes_encode_from_slice(&payload, data, args.size);
z_bytes_serialize_from_slice(&payload, data, args.size);
z_publisher_put(z_loan(pub), z_move(payload), NULL);
int s = z_condvar_wait(z_loan(cond), z_loan_mut(mutex));
if (s != 0) {
Expand All @@ -89,7 +89,7 @@ int main(int argc, char** argv) {
}
unsigned long* results = z_malloc(sizeof(unsigned long) * args.number_of_pings);
for (int i = 0; i < args.number_of_pings; i++) {
z_bytes_encode_from_slice(&payload, data, args.size);
z_bytes_serialize_from_slice(&payload, data, args.size);
z_clock_t measure_start = z_clock_now();
z_publisher_put(z_loan(pub), z_move(payload), NULL);
int s = z_condvar_wait(z_loan(cond), z_loan_mut(mutex));
Expand Down
2 changes: 1 addition & 1 deletion examples/z_ping_shm.c
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ int main(int argc, char** argv) {

unsigned long elapsed_us = 0;
while (elapsed_us < args.warmup_ms * 1000) {
z_bytes_encode_from_shm_copy(&payload, loaned_shm);
z_bytes_serialize_from_shm_copy(&payload, loaned_shm);
z_publisher_put(z_loan(pub), z_move(payload), NULL);
int s = z_condvar_wait(z_loan(cond), z_loan_mut(mutex));
if (s != 0) {
Expand Down
2 changes: 1 addition & 1 deletion examples/z_pub.c
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ int main(int argc, char **argv) {
z_publisher_put_options_default(&options);

z_owned_bytes_t payload;
z_bytes_encode_from_string(&payload, buf);
z_bytes_serialize_from_string(&payload, buf);

z_publisher_put(z_loan(pub), z_move(payload), &options);
}
Expand Down
10 changes: 5 additions & 5 deletions examples/z_pub_attachment.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@ bool create_attachment_iter(z_owned_bytes_t* kv_pair, void* context) {
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);
z_bytes_encode_from_pair(kv_pair, z_move(k), z_move(v));
z_bytes_serialize_from_string(&k, kvs->data[kvs->current_idx].key);
z_bytes_serialize_from_string(&v, kvs->data[kvs->current_idx].value);
z_bytes_serialize_from_pair(kv_pair, z_move(k), z_move(v));
kvs->current_idx++;
return true;
}
Expand Down Expand Up @@ -95,13 +95,13 @@ 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};
z_bytes_encode_from_iter(&attachment, create_attachment_iter, (void*)&ctx);
z_bytes_serialize_from_iter(&attachment, create_attachment_iter, (void*)&ctx);
options.attachment = &attachment;

sprintf(buf, "[%4d] %s", idx, value);
printf("Putting Data ('%s': '%s')...\n", keyexpr, buf);

z_bytes_encode_from_string(&payload, buf);
z_bytes_serialize_from_string(&payload, buf);
z_publisher_put(z_loan(pub), z_move(payload), &options);
}

Expand Down
2 changes: 1 addition & 1 deletion examples/z_pub_cache.c
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ int main(int argc, char **argv) {
sprintf(buf, "[%4d] %s", idx, value);
printf("Putting Data ('%s': '%s')...\n", keyexpr, buf);
z_owned_bytes_t payload;
z_bytes_encode_from_string(&payload, buf);
z_bytes_serialize_from_string(&payload, buf);

z_put(z_loan(s), z_loan(ke), z_move(payload), NULL);
}
Expand Down
2 changes: 1 addition & 1 deletion examples/z_pub_shm.c
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ int main(int argc, char **argv) {
z_publisher_put_options_default(&options);

z_owned_bytes_t payload;
z_bytes_encode_from_shm_mut(&payload, &shm_buf);
z_bytes_serialize_from_shm_mut(&payload, &shm_buf);

z_publisher_put(z_loan(pub), z_move(payload), &options);
} else {
Expand Down
2 changes: 1 addition & 1 deletion examples/z_pub_shm_thr.c
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ int main(int argc, char **argv) {

z_owned_bytes_t payload;
while (1) {
z_bytes_encode_from_shm_copy(&payload, loaned_shm);
z_bytes_serialize_from_shm_copy(&payload, loaned_shm);
z_publisher_put(z_loan(pub), z_move(payload), NULL);
}

Expand Down
2 changes: 1 addition & 1 deletion examples/z_pub_thr.c
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ int main(int argc, char **argv) {

z_owned_bytes_t payload;
while (1) {
z_bytes_encode_from_slice(&payload, value, len);
z_bytes_serialize_from_slice(&payload, value, len);
z_publisher_put(z_loan(pub), z_move(payload), NULL);
}

Expand Down
2 changes: 1 addition & 1 deletion examples/z_pull.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ void handle_sample(const z_loaned_sample_t *sample) {
z_view_string_t keystr;
z_keyexpr_as_view_string(z_sample_keyexpr(sample), &keystr);
z_owned_string_t payload_value;
z_bytes_decode_into_string(z_sample_payload(sample), &payload_value);
z_bytes_deserialize_into_string(z_sample_payload(sample), &payload_value);
printf(">> [Subscriber] Received %s ('%.*s': '%.*s')\n", kind_to_str(z_sample_kind(sample)),
(int)z_string_len(z_loan(keystr)), z_string_data(z_loan(keystr)), (int)z_string_len(z_loan(payload_value)),
z_string_data(z_loan(payload_value)));
Expand Down
8 changes: 4 additions & 4 deletions examples/z_put.c
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,12 @@ int main(int argc, char **argv) {
z_view_keyexpr_from_string(&ke, keyexpr);

z_owned_bytes_t payload;
z_bytes_encode_from_string(&payload, value);
z_bytes_serialize_from_string(&payload, value);

z_owned_bytes_t attachment, key, val;
z_bytes_encode_from_string(&key, "hello");
z_bytes_encode_from_string(&val, "there");
z_bytes_encode_from_pair(&attachment, z_move(key), z_move(val));
z_bytes_serialize_from_string(&key, "hello");
z_bytes_serialize_from_string(&val, "there");
z_bytes_serialize_from_pair(&attachment, z_move(key), z_move(val));

z_put_options_t options;
z_put_options_default(&options);
Expand Down
2 changes: 1 addition & 1 deletion examples/z_query_sub.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ void data_handler(const z_loaned_sample_t *sample, void *arg) {
z_keyexpr_as_view_string(z_sample_keyexpr(sample), &key_string);

z_owned_string_t payload_string;
z_bytes_decode_into_string(z_sample_payload(sample), &payload_string);
z_bytes_deserialize_into_string(z_sample_payload(sample), &payload_string);

printf(">> [Subscriber] Received %s ('%.*s': '%.*s')\n", kind_to_str(z_sample_kind(sample)),
(int)z_string_len(z_loan(key_string)), z_string_data(z_loan(key_string)),
Expand Down
4 changes: 2 additions & 2 deletions examples/z_queryable.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ void query_handler(const z_loaned_query_t *query, void *context) {
const z_loaned_bytes_t *payload = z_query_payload(query);
if (z_bytes_len(payload) > 0) {
z_owned_string_t payload_string;
z_bytes_decode_into_string(payload, &payload_string);
z_bytes_deserialize_into_string(payload, &payload_string);

printf(">> [Queryable ] Received Query '%.*s?%.*s' with value '%.*s'\n", (int)z_string_len(z_loan(key_string)),
z_string_data(z_loan(key_string)), (int)z_string_len(z_loan(params)), z_string_data(z_loan(params)),
Expand All @@ -44,7 +44,7 @@ void query_handler(const z_loaned_query_t *query, void *context) {
z_query_reply_options_default(&options);

z_owned_bytes_t reply_payload;
z_bytes_encode_from_string(&reply_payload, value);
z_bytes_serialize_from_string(&reply_payload, value);

z_view_keyexpr_t reply_keyexpr;
z_view_keyexpr_from_string(&reply_keyexpr, (const char *)context);
Expand Down
4 changes: 2 additions & 2 deletions examples/z_queryable_with_channels.c
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ int main(int argc, char **argv) {
const z_loaned_bytes_t *payload = z_query_payload(query);
if (z_bytes_len(payload) > 0) {
z_owned_string_t payload_string;
z_bytes_decode_into_string(payload, &payload_string);
z_bytes_deserialize_into_string(payload, &payload_string);

printf(">> [Queryable ] Received Query '%.*s?%.*s' with value '%.*s'\n",
(int)z_string_len(z_loan(key_string)), z_string_data(z_loan(key_string)),
Expand All @@ -89,7 +89,7 @@ int main(int argc, char **argv) {
z_query_reply_options_default(&options);

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), &options);
z_drop(z_move(oquery));
}
Expand Down
2 changes: 1 addition & 1 deletion examples/z_sub.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ void data_handler(const z_loaned_sample_t *sample, void *arg) {
z_keyexpr_as_view_string(z_sample_keyexpr(sample), &key_string);

z_owned_string_t payload_string;
z_bytes_decode_into_string(z_sample_payload(sample), &payload_string);
z_bytes_deserialize_into_string(z_sample_payload(sample), &payload_string);

printf(">> [Subscriber] Received %s ('%.*s': '%.*s')\n", kind_to_str(z_sample_kind(sample)),
(int)z_string_len(z_loan(key_string)), z_string_data(z_loan(key_string)),
Expand Down
8 changes: 4 additions & 4 deletions examples/z_sub_attachment.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ void data_handler(const z_loaned_sample_t *sample, void *arg) {
z_keyexpr_as_view_string(z_sample_keyexpr(sample), &key_string);

z_owned_string_t payload_string;
z_bytes_decode_into_string(z_sample_payload(sample), &payload_string);
z_bytes_deserialize_into_string(z_sample_payload(sample), &payload_string);

printf(">> [Subscriber] Received %s ('%.*s': '%.*s')\n", kind_to_str(z_sample_kind(sample)),
(int)z_string_len(z_loan(key_string)), z_string_data(z_loan(key_string)),
Expand All @@ -38,10 +38,10 @@ void data_handler(const z_loaned_sample_t *sample, void *arg) {
while (z_bytes_iterator_next(&iter, &kv)) {
z_owned_bytes_t k, v;
z_owned_string_t key, value;
z_bytes_decode_into_pair(z_loan(kv), &k, &v);
z_bytes_deserialize_into_pair(z_loan(kv), &k, &v);

z_bytes_decode_into_string(z_loan(k), &key);
z_bytes_decode_into_string(z_loan(v), &value);
z_bytes_deserialize_into_string(z_loan(k), &key);
z_bytes_deserialize_into_string(z_loan(v), &value);

printf(" attachment: %.*s: '%.*s'\n", (int)z_string_len(z_loan(key)), z_string_data(z_loan(key)),
(int)z_string_len(z_loan(value)), z_string_data(z_loan(value)));
Expand Down
Loading
Loading