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

Rework of message and option parsing #21

Open
2 tasks
pulsastrix opened this issue Jul 19, 2024 · 0 comments
Open
2 tasks

Rework of message and option parsing #21

pulsastrix opened this issue Jul 19, 2024 · 0 comments
Labels
enhancement New feature or request
Milestone

Comments

@pulsastrix
Copy link
Member

The current way that messages and options are handled is rather inefficient, as it requires cloning most CoAP options when converting from and to raw messages.

A main reason for why this is necessary is that the message types are mutable, which requires message construction to only happen at the very end.

In order to reduce this overhead and get closer to a "zero-cost abstraction", I propose making the following changes:

  • Rewrite the CoapOption type so that it acts as a wrapper around a raw CoAP option (similar to the changes to CoapUris in feat: improve URI handling by basing it on the libcoap type #18).
    • This might require some more involved changes, as CoAP options are represented in two different structs inside of libcoap (coap_optlist_t during PDU setup, coap_opt_t during PDU parsing)
    • Additionally, lifetime issues need to be considered. coap_opt_t instances are basically a view into the underlying PDU, and therefore must not outlive it.
  • Separate CoapMessage, CoapRequest and CoapResponse into a read-only wrapper around coap_pdu_t (again, similar to feat: improve URI handling by basing it on the libcoap type #18) and a write-only builder structure.
    • The read-only wrappers will read option values as references from the underlying coap_pdu_t and not store them as copies (as is currently done).
      • There should be methods both for getting specific options (which would require a search through the option list each time) and for iterating over the list of options (maybe even supporting filters)
    • The write-only builders will be a wrapper around an internal coap_pdu_t for basic attributes as well as a coap_optlist_t for setting option values.
@pulsastrix pulsastrix added this to the v0.3.0 milestone Jul 19, 2024
@pulsastrix pulsastrix added the enhancement New feature or request label Jul 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant