fts_server/utils/
now.rs

1use axum::{extract::FromRequestParts, http::request::Parts};
2use time::OffsetDateTime;
3
4/// A wrapper for the current time in UTC.
5///
6/// This struct provides the current UTC time as an extractor,
7/// allowing handlers to easily access a consistent timestamp
8/// during request processing.
9pub struct Now(pub OffsetDateTime);
10
11impl<S> FromRequestParts<S> for Now
12where
13    S: Send + Sync,
14{
15    type Rejection = std::convert::Infallible;
16
17    async fn from_request_parts(_: &mut Parts, _: &S) -> Result<Self, Self::Rejection> {
18        Ok(Now(time::OffsetDateTime::now_utc()))
19    }
20}