summaryrefslogtreecommitdiff
path: root/crates/tor-hscrypto/src
diff options
context:
space:
mode:
Diffstat (limited to 'crates/tor-hscrypto/src')
-rw-r--r--crates/tor-hscrypto/src/time.rs16
1 files changed, 16 insertions, 0 deletions
diff --git a/crates/tor-hscrypto/src/time.rs b/crates/tor-hscrypto/src/time.rs
index 5231bc98c..4ce718a96 100644
--- a/crates/tor-hscrypto/src/time.rs
+++ b/crates/tor-hscrypto/src/time.rs
@@ -125,6 +125,22 @@ impl TimePeriod {
(SystemTime::UNIX_EPOCH + epoch_offset).checked_add(Duration::from_secs(end_sec))?;
Some(start..end)
}
+
+ /// Return the numeric index of this time period.
+ ///
+ /// This function should only be used when encoding the time period for
+ /// cryptographic purposes.
+ pub fn interval_num(&self) -> u64 {
+ self.interval_num
+ }
+
+ /// Return the length of this time period as a number of seconds.
+ ///
+ /// This function should only be used when encoding the time period for
+ /// cryptographic purposes.
+ pub fn length_in_sec(&self) -> u64 {
+ self.length_in_sec.into()
+ }
}
#[cfg(test)]