iotaledger / backstage

Apache License 2.0
0 stars 0 forks source link

Allow `IntervalChannel` to be used with `std::time::Duration` #12

Open grtlr opened 2 years ago

grtlr commented 2 years ago

Motivation

It would be great if IntervalChannel could be used with std::time::Duration as that would lead to more self-documenting code.

Open questions

Since std::time::Duration is mostly const this could even be performed at compile time.

Are you planning to do it yourself in a pull request?

Yes/No.

louaykamel commented 2 years ago

Pushed

louaykamel commented 2 years ago

Reopen (if needed)

grtlr commented 2 years ago

Could you please add an example on how to use this? With the regular interval channel the duration is passed in at compile time as a const generic. How would that work for std::time::Duration? Thanks!

louaykamel commented 2 years ago

Pass the std::time::Duration using spawn_with_channel/start_with_channel
Or impl ChannelBuilder<Duration> for YourActor.

I will add an example

grtlr commented 2 years ago

Cool, thank you!