zbus-old icon indicating copy to clipboard operation
zbus-old copied to clipboard

MessageBuilder related work

Open zeenix opened this issue 4 years ago • 4 comments

In GitLab by @danieldg on Aug 29, 2021, 03:25

Ideas for future work:

  • Bind a Message to a Connection so the serial number gets set in MessageBuilder
  • Parse out the header of a Message in the struct during decoding. This would allow making MessageFields private and have all access to headers be via method on Message that return Options instead of Result<Option<HeaderValue>>. Might get some minor speedups from having the values pre-parsed.

See !364

zeenix avatar Aug 29 '21 01:08 zeenix

In GitLab by @danieldg on Sep 29, 2021, 02:39

The second part was mostly done by !391 - though we could perhaps improve that by making those method not return Result as they are not supposed to fail give a valid Message (and all Message objects should be valid).

zeenix avatar Sep 29 '21 00:09 zeenix

This would allow making MessageFields private and have all access to headers be via method on Message that return Options instead of Result<Option<HeaderValue>>

Not sure this is a good idea. How would header attribute of dbus_interface methods work then? You'd need individual attributes for each field passed separately then. OTOH if we keep MessageFields around, I'm wondering why the message header/fields API can't be modified to always keep the headers in the decoded form (rather than Message doing that)?

zeenix avatar Sep 29 '21 11:09 zeenix

In GitLab by @danieldg on Sep 29, 2021, 17:52

You could swap that out for a message attribute instead. Or make a wrapper around Message (distinct from MessageFields) that only allows access to the header, but I don't see a need for that.

zeenix avatar Sep 29 '21 15:09 zeenix

I think I'm going to postpone this for zbus 3.0 because:

  1. Most important bits of this are already in place, I believe.
  2. It's mostly about convenience of the low-level API and I think that's already pretty convenient so don't think this is very high priority.
  3. Attaching the message to a connection, needs further thinking since so far, message and connection have been very detached from each other.
  4. @danieldg neither you, nor I have lately been able to get much time for zbus dev and 2.0 has been pending for more than 6 months at least.

zeenix avatar Dec 23 '21 15:12 zeenix