Skip to content

Documentation: AddProgress::stream() guaranteed to always yield at least one item? #244

Description

@matthiasbeyer

I would like to see a small documentation improvement on AddProgress::stream() (which currently has no documentation itself: https://docs.rs/iroh-blobs/latest/iroh_blobs/api/blobs/struct.AddProgress.html#method.stream)).

From the docs of (AddProgressItem)[https://docs.rs/iroh-blobs/latest/iroh_blobs/api/blobs/enum.AddProgressItem.html] it seems to me that the stream is always guaranteed to yield at least one element.

That should (IMHO) be stated on the AddProgress::stream() method. Using code like

loop {
    let Some(next_item) = stream.next().await else { unreachable!() };
    // processing the item and breaking the loop in case of a known-to-be-last-element item
}

would be possible (the bit with the unreachable!()). Otherwise I would need to handle the stream.next() -> None situation.

Please consider adding approriate documentation to AddProgress::stream()

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Status
    🚑 Needs Triage

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions