Skip to content

refactor: generic recv_optional helper #300

@bug-ops

Description

@bug-ops

Context

Two identical free functions in zeph-core agent module differ only in type parameter:

async fn recv_skill_event(rx: &mut Option<mpsc::Receiver<SkillEvent>>) -> Option<SkillEvent> { ... }
async fn recv_config_event(rx: &mut Option<mpsc::Receiver<ConfigEvent>>) -> Option<ConfigEvent> { ... }

Proposed change

Replace with a single generic helper:

async fn recv_optional<T>(rx: &mut Option<mpsc::Receiver<T>>) -> Option<T> {
    match rx {
        Some(rx) => rx.recv().await,
        None => std::future::pending().await,
    }
}

Affected crates

zeph-core

Complexity

Trivial

References

.local/plan/architecture-audit.md — Phase 4, item 4.2

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions