FactbirdHQ / mqttrust

MQTT client for embedded devices, written in rust
53 stars 5 forks source link

Minor changes to event loop, lifetime and event selection #22

Closed keisrk closed 3 years ago

keisrk commented 3 years ago

Rumqtt uses select! macro for matching incoming events. Moreover it adopts BytesMut, a shareable smart pointer on heap. The both are not available for no_std, no_alloc embedded environment. As a result it makes lifetime management cumbersome.

Admittedly less declarative compared to the original select! flow, this PR uses a simple imperative style to process each event one by one.

Each commit builds and passes tests.

  1. By design, yield_event is not meant to return an error value other than WouldBlock. Made the contract explicit by using Infallible.
  2. Simplified select!-like flow.
codecov-io commented 3 years ago

Codecov Report

Merging #22 (b4ebb0a) into master (d54fea0) will decrease coverage by 0.91%. The diff coverage is 20.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master      #22      +/-   ##
==========================================
- Coverage   41.50%   40.58%   -0.92%     
==========================================
  Files           4        4              
  Lines         506      510       +4     
  Branches      149      158       +9     
==========================================
- Hits          210      207       -3     
- Misses        218      225       +7     
  Partials       78       78              
Impacted Files Coverage Δ
src/lib.rs 12.43% <0.00%> (-0.32%) :arrow_down:
src/state.rs 34.22% <54.54%> (-1.42%) :arrow_down:

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update d54fea0...b4ebb0a. Read the comment docs.

MathiasKoch commented 3 years ago

Could you rebase this?

keisrk commented 3 years ago

Sure, it's on master now.