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

Add z_bytes example #673

Merged
merged 16 commits into from
Sep 20, 2024
Merged

Conversation

jean-roland
Copy link
Contributor

@jean-roland jean-roland commented Sep 16, 2024

Closes #662.

Adds missing encoding constants.

@jean-roland jean-roland added the enhancement Things could work better label Sep 16, 2024
@jean-roland jean-roland marked this pull request as ready for review September 17, 2024 13:03
src/api/api.c Outdated Show resolved Hide resolved
// Constant alias for string: `"zenoh/bytes"`.
//
// Usually used for types: `uint8_t[]`.
extern const z_owned_encoding_t ENCODING_ZENOH_BYTES;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@DenisBiryukov91
Copy link
Contributor

DenisBiryukov91 commented Sep 19, 2024

We will also need to add the docs for encoding functions, and probably an example of using slice iterator similar to https://github.com/eclipse-zenoh/zenoh/blob/db755e3e75733b10cd9b9fa63acb624fd4e57a39/examples/examples/z_bytes.rs#L107C1-L112C6

z_view_slice_t curr_slice;
while (z_bytes_slice_iterator_next(&slice_iter, &curr_slice)) {
printf("slice len: %d, slice data: '%.*s'\n", (int)z_slice_len(z_view_slice_loan(&curr_slice)),
(int)z_slice_len(z_view_slice_loan(&curr_slice)),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is not good since it will print garbage, could we rather print slice content as list of hexadecimal values ?

@jean-roland jean-roland force-pushed the ft_zbytes_example branch 5 times, most recently from 3d3b42e to 6f3a235 Compare September 19, 2024 14:21
@gabrik gabrik merged commit b4f07f3 into eclipse-zenoh:main Sep 20, 2024
54 checks passed
@jean-roland jean-roland deleted the ft_zbytes_example branch October 8, 2024 07:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Things could work better
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add z_bytes example
4 participants