Closed ewpratten closed 3 years ago
I don't think there is any need to deprecate timestamps
, there are situations where where having a single method can be more convenient compared to 2 separate builder methods. Everything else looks good though (well, other than the rustfmt issues)!
Alright. Both of those should be addressed now.
Checklist
Description of Changes
After working with this crate in a recent project, the largest headache I encountered was the lack of ability to set just a start timestamp on activity (to get the
(xx:xx elapsed)
message in my status).This PR adds two new methods to
ActivityBuilder
and slightly changesIntoTimestamp
andTimestamps
to add this ability.I have added
ActivityBuilder::start_timestamp
andActivityBuilder::end_timestamp
which both set only their respective timestamp values when called.I have also deprecated, and changed its code to just callActivityBuilder::timestamps
(although this can be undone)start_timestamp
andend_timestamp
. (Important note, calling both methods together will set a time range, liketimestamps
does)Both the
start_timestamp
andend_timestamp
now take a genericT: IntoTimestamp
instead of animpl IntoTimestamp
since the Rust compiler seems to dislike the old way, throwing errors when the method is called.I have added an
IntoTimestamp
impl fori64
, so crate users can easily enter a unix timestamp as an integer (more useful for testing than anything).Finally, to make setting only one timestamp at a time possible, I have added serde annotations to
Timestamps
to skip serialization of empty fields.I'll be keeping an eye on this PR for any requested changes, or comments.
Related Issues
None