pactum_annotations/context.rs
1/// Pure context passed into `validate_with` so time-based checks stay deterministic.
2#[derive(Debug, Clone, Copy, Default, PartialEq, Eq, Hash)]
3pub struct ValidationContext {
4 /// Unix epoch milliseconds. Required by `timestamp_ms(after_now)` / `before_now`.
5 pub now_ms: Option<i64>,
6}
7
8impl ValidationContext {
9 #[must_use]
10 pub const fn new() -> Self {
11 Self { now_ms: None }
12 }
13
14 #[must_use]
15 pub const fn with_now_ms(now_ms: i64) -> Self {
16 Self {
17 now_ms: Some(now_ms),
18 }
19 }
20}