quartiq / minimq

Minimal no_std MQTT v5.0 client implementation
MIT License
143 stars 16 forks source link

Elevating ToPayload to FnOnce, adding ToPayload for &str #152

Closed ryan-summers closed 11 months ago

ryan-summers commented 12 months ago

The DeferredPayload needs to be FnOnce (or FnMut) if we want the user to be able to mutate data within a deferred payload calculation.

This is necessary for things like i.e. minireq, where the user is going to be doing application-level logic within a DeferredPayload calculation, which may necessitate mutation of data and context.

I also implemented ToPayload for &str so you can now call Publication::new("Hello") without having to call as_bytes() on the str.