project-chip / rs-matter

Rust implementation of the Matter protocol. Status: Experimental
Apache License 2.0
310 stars 43 forks source link

Allow buffer sharing between mDNS and Matter transport; const-ify constructors #138

Closed ivmarkov closed 5 months ago

ivmarkov commented 5 months ago

The built-in mDNS implementation is adjusted in such a way, that it can share and re-use the RX/TX pair of buffers which are also used by the exchange/Matter transport layer. While not an enormous memory saving (~ 3K), it paves the way for the upcoming changes to the Exchange layer itself, where the existing PacketBuffers structure (~ 25K) is gone and everything works with this single RX/TX pair - at least with regards to the exchange layer (Secure Channel won't need extra RX/TX either, the IM layer is another story but still overall a big win).

Additional gains:

Finally, the changes from above no longer force the user to create the mDNS service separately - as long as the user is not providing their own one to the Matter object (MdnsService::Provided(_)), the Matter constructor will just construct our pure-Rust one, or the Bonjour one or the Avahi one, depending on the OS.