summaryrefslogtreecommitdiff
path: root/crates/tor-checkable
diff options
context:
space:
mode:
Diffstat (limited to 'crates/tor-checkable')
-rw-r--r--crates/tor-checkable/Cargo.toml13
-rw-r--r--crates/tor-checkable/src/timed.rs35
2 files changed, 42 insertions, 6 deletions
diff --git a/crates/tor-checkable/Cargo.toml b/crates/tor-checkable/Cargo.toml
index e95e07865..949cbc311 100644
--- a/crates/tor-checkable/Cargo.toml
+++ b/crates/tor-checkable/Cargo.toml
@@ -6,14 +6,15 @@ edition = "2018"
license = "MIT OR Apache-2.0"
homepage = "https://gitlab.torproject.org/tpo/core/arti/-/wikis/home"
description = "Types to ensure that signed or time-bound data is validated before use"
-keywords = [ "tor", "arti", "typestate" ]
-categories = [ "cryptography", "rust-patterns" ]
-repository="https://gitlab.torproject.org/tpo/core/arti.git/"
+keywords = ["tor", "arti", "typestate"]
+categories = ["cryptography", "rust-patterns"]
+repository = "https://gitlab.torproject.org/tpo/core/arti.git/"
+
+[features]
+experimental-api = []
[dependencies]
-tor-llcrypto = { path="../tor-llcrypto", version = "0.1.0"}
+tor-llcrypto = { path = "../tor-llcrypto", version = "0.1.0" }
signature = "1"
thiserror = "1"
-
-
diff --git a/crates/tor-checkable/src/timed.rs b/crates/tor-checkable/src/timed.rs
index ee8972460..e83da93c4 100644
--- a/crates/tor-checkable/src/timed.rs
+++ b/crates/tor-checkable/src/timed.rs
@@ -79,6 +79,41 @@ impl<T> TimerangeBound<T> {
let start = self.start.map(|t| t - d);
Self { start, ..self }
}
+
+ /// Consume this TimeRangeBound, and return its underlying time bounds and
+ /// object.
+ ///
+ /// The caller takes responsibility for making sure that the bounds are
+ /// actually checked.
+ ///
+ /// This is an experimental API. Using it voids your stability guarantees.
+ /// It is only available when this crate is compiled with the
+ /// `experimental-api` feature.
+ #[cfg(feature = "experimental-api")]
+ pub fn dangerously_into_parts(self) -> (T, (Bound<time::SystemTime>, Bound<time::SystemTime>)) {
+ (
+ self.obj,
+ (
+ self.start.map(Bound::Included).unwrap_or(Bound::Unbounded),
+ self.end.map(Bound::Included).unwrap_or(Bound::Unbounded),
+ ),
+ )
+ }
+
+ /// Return a reference to the inner object of this TimeRangeBound, without
+ /// checking the time interval.
+ ///
+ /// The caller takes responsibility for making sure that nothing is actually
+ /// done with the inner object that would rely on the bounds being correct, until
+ /// the bounds are (eventually) checked.
+ ///
+ /// This is an experimental API. Using it voids your stability guarantees.
+ /// It is only available when this crate is compiled with the
+ /// `experimental-api` feature.
+ #[cfg(feature = "experimental-api")]
+ pub fn dangerously_peek(&self) -> &T {
+ &self.obj
+ }
}
impl<T> crate::Timebound<T> for TimerangeBound<T> {