Repository navigation
Move 26 run_worker command bodies into worker_commands.rs - #231
Merged
Merged
Conversation
Fifth step of splitting main.rs, first part: the bodies of 26 arms of run_worker (selecting a network, the directory, the admin edits, the personal preferences, ignore, notify and watch lists and a few more) become run_* functions in src/worker_commands.rs, called in place. The loop, the select!, every arm pattern and guard and the order of events stay exactly as they were. Arms that touch the session events or the radio locals, return or use ?, or would need more than seven parameters stay inline. No behaviour change. Refs #206.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Refs #206.
Step 5 of the split of
main.rs, first part (run_worker). The bodies of 26 arms (of 139) move intorun_<command>functions in the newcrates/cordiale-ui/src/worker_commands.rs, and each arm now just calls its helper, with.awaitexactly when the helper isasync.run_workergoes from 1,237 to 996 lines andmain.rsfrom 12,630 to 12,391. The frame is untouched: theloop, thematch &mut session_events, theselect!, every arm pattern and guard, so the order of events is preserved by construction. The issue stays open for the last part (main()).Which arms moved: only those with a body of ten lines or more that contain no
return,?, label,breakorcontinue, assign or borrow mutably norun_workerlocal other thanstate, need at most seven parameters and have only parameters and pattern bindings of declared types as free variables. The other 113 stay inline: 103 are shorter than ten lines, five usesession_events(Connect,TotpVerify,ShareConsume,RecoverySignIn,PasskeySignIn), two use the radio locals (RadioTrack,Disconnect), two would need more than seven parameters (AdminServerEdit,AdminCredentialEdit) and one is theNone => returnframe arm. The helpers takestate: &mut WorkerStateandui: &slint::Weak<AppWindow>like the existing handlers, plus the arm's bindings with the types of theWorkerCommandfields. They are namedrun_*(no existing item has those names).Checked by script: every helper body equals the original arm body after one normalisation that moving the code requires (
&mut stateand&statebecomestate,&uibecomesui, since they are references already: otherwise&mut statewould be a&mut &mutand&uitripsneedless_borrow); every parameter is used and every call passes exactly the names the body needs; noreturn,?, label,breakorcontinuein a helper; the token stream ofmain.rswith the 26 bodies masked is identical to the original except themodanduselines; the#[test]count is unchanged (305). The CI log should show the same test counts asmain(390 forcordiale-ui). Not verified: nothing is compiled before CI. Disjoint field borrows through the&mutreference (the notify and admin refresh arms) and the futures'Send-ness are the points to watch.Branch:
enhancement-issue-206-worker