tg-rs / carapax

A Telegram Bot API framework
MIT License
113 stars 12 forks source link

Add App, reduce Dispatcher to a list of handlers #72

Closed rossnomann closed 2 years ago

rossnomann commented 2 years ago

App contains context, dispatcher and error handler.

Dispatcher now contains only a Vec of handlers. Also it implements Handler trait and we can use dispatcher in predicates.

DispatcherBuilder exists because Dispatcher contains Arc<Vec<_>> in order to clone handlers list cheaply. Alternatively we need to use a Mutex and it is not a good decision.

InputHandler trait used because Handler requires Clone and it ruines object safety.

codecov-commenter commented 2 years ago

Codecov Report

Merging #72 (fcc6376) into master (f673dbc) will decrease coverage by 0.28%. The diff coverage is 87.64%.

:exclamation: Current head fcc6376 differs from pull request most recent head 3fa4dea. Consider uploading reports for the commit 3fa4dea to get more accurate results Impacted file tree graph

@@            Coverage Diff             @@
##           master      #72      +/-   ##
==========================================
- Coverage   83.03%   82.75%   -0.29%     
==========================================
  Files          16       19       +3     
  Lines         501      516      +15     
==========================================
+ Hits          416      427      +11     
- Misses         85       89       +4     
Impacted Files Coverage Δ
src/core/predicate/base.rs 100.00% <ø> (ø)
src/core/predicate/command.rs 100.00% <ø> (ø)
src/core/predicate/ext.rs 0.00% <0.00%> (ø)
src/dialogue/mod.rs 71.42% <ø> (ø)
src/core/dispatcher.rs 90.00% <88.23%> (-4.12%) :arrow_down:
src/core/app.rs 88.88% <88.88%> (ø)
src/core/handler.rs 100.00% <100.00%> (ø)
src/core/predicate/result.rs 100.00% <100.00%> (ø)
src/core/convert.rs 62.74% <0.00%> (-0.99%) :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 f673dbc...3fa4dea. Read the comment docs.