Conversation
Reviewer's GuideThis PR consolidates polling logic by replacing the two specialized helpers (poll_receiver and poll_response) with a single generic poll_if_present function, and updates all call sites in the connection loop to use the new helper. Class diagram for consolidated polling helpersclassDiagram
class Connection {
+poll_if_present<'a, T, Fut, R>(opt: Option<&'a mut T>, f: impl FnOnce(&'a mut T) -> Fut + 'a) -> impl Future<Output = Option<R>> + 'a
+recv_push(rx: &mut mpsc::Receiver<F>) -> Option<F>
}
%% Removed helpers
class poll_receiver {
-poll_receiver(rx: Option<&mut mpsc::Receiver<F>>) -> impl Future<Output = Option<F>>
}
class poll_response {
-poll_response(stream: Option<&mut FrameStream<F, E>>) -> impl Future<Output = Option<Result<F, WireframeError<E>>>>
}
Connection --|> poll_receiver : replaced
Connection --|> poll_response : replaced
%% New generic helper
class poll_if_present {
+poll_if_present<'a, T, Fut, R>(opt: Option<&'a mut T>, f: impl FnOnce(&'a mut T) -> Fut + 'a) -> impl Future<Output = Option<R>> + 'a
}
Connection --> poll_if_present : uses
File-Level Changes
Possibly linked issues
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
Summary by CodeRabbit
WalkthroughThe code refactors the polling logic in the Changes
Sequence Diagram(s)sequenceDiagram
participant Caller
participant ConnectionActor
participant OptionalSource
Caller->>ConnectionActor: poll_optional(opt, closure)
alt opt is Some
ConnectionActor->>OptionalSource: closure(&mut T) (returns Future)
OptionalSource-->>ConnectionActor: Option<R>
ConnectionActor-->>Caller: Option<R>
else opt is None
ConnectionActor-->>Caller: None
end
Possibly related PRs
Poem
📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (1)
🧰 Additional context used📓 Path-based instructions (2)`**/*.rs`: Comment why, not what. Explain assumptions, edge cases, trade-offs, o...
📄 Source: CodeRabbit Inference Engine (AGENTS.md) List of files the instruction was applied to:
`**/*.rs`: * Seek to keep the cyclomatic complexity of functions no more than 12...
⚙️ Source: CodeRabbit Configuration File List of files the instruction was applied to:
⏰ Context from checks skipped due to timeout of 90000ms (2)
🔇 Additional comments (5)
✨ Finishing Touches
🧪 Generate Unit Tests
🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Hey @leynos - I've reviewed your changes - here's some feedback:
- Consider renaming
poll_if_presentto something more descriptive (for examplepoll_optional) to make its purpose clearer at call sites. - The generic signature of
poll_if_presentis quite verbose—consider introducing a type alias or helper trait to hide some of the future/bound boilerplate and improve readability.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- Consider renaming `poll_if_present` to something more descriptive (for example `poll_optional`) to make its purpose clearer at call sites.
- The generic signature of `poll_if_present` is quite verbose—consider introducing a type alias or helper trait to hide some of the future/bound boilerplate and improve readability.Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
Summary
Testing
make lintmake testhttps://chatgpt.com/codex/tasks/task_e_686720b7d1948322b97e3ae684bf27e9
Summary by Sourcery
Consolidate polling logic for optional asynchronous sources by replacing specialized helper methods with a generic
poll_if_presentfunction.Enhancements:
poll_receiverandpoll_responsewith a unified genericpoll_if_presentmethod for optional streams and receiverspoll_if_presentfor high, low, and response polling