Skip to content

Events::oldest_event_count and Events::oldest_id don't make the difference to each other clear enough #15617

@urben1680

Description

@urben1680

I am not certain if this is a docs issue, but I found this by looking at the source, not by encountering some bug. That is why for now I focused on how the API appears while there are more issues.

The methods Events::oldest_event_count and Events::oldest_id seem to do the same thing when looked at the docs or the source.

Also the API itself is confusing. Instead of returning usize it should return an Option<EventId<E>> because no oldest event might be available currently if the sequences events_b and events_a are empty.

As a side note, the implementation of oldest_event_count looks like that:

/// Returns the index of the oldest event stored in the event buffer.
pub fn oldest_event_count(&self) -> usize {
    self.events_a
        .start_event_count
        .min(self.events_b.start_event_count)
}

When it should be clear that self.events_b as the more recent sequence cannot contain the oldest count.

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-DocsAn addition or correction to our documentationS-Needs-TriageThis issue needs to be labelled

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions