Skip to content

what about implementing Future<Result<(), IoError>> for Interval #5

Description

@jimy-byerley

Hello there
Thank you very much for featuring timerfd to tokio, it saved my realtime applications in etherage

At the moment, tokio_timerfd::Interval can only be used as an async iterator (or close to it, since rust truly supports async iterators) through the trait Stream, however it does not bring much more than a mere Future

  • no nice syntax using stream
  • more complex call to the timer

From a user point of view, using Interval as a Stream leads to a weird line like this

let interval = Interval::new_interval(...);
interval.next().await.unwrap()?;

as a Future it could be more straight forward

let interval = Interval::new_interval(...);
interval.await?;

Looking at the current implementation of Stream, it looks like Future could be implemented using the exact same code. Do you think an impl Future could be added mirroring Stream (or vice-versa) ?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions