pub struct TemplateMetadata { /* private fields */ }Expand description
Metadata about template generation.
This struct is designed to be flattened into template contexts using #[serde(flatten)],
making the timestamp available at the top level in templates.
§Example
use torrust_tracker_deployer_lib::infrastructure::templating::metadata::TemplateMetadata;
use chrono::{TimeZone, Utc};
let timestamp = Utc.with_ymd_and_hms(2026, 1, 27, 14, 30, 0).unwrap();
let metadata = TemplateMetadata::new(timestamp);
assert_eq!(metadata.generated_at(), ×tamp);Implementations§
Source§impl TemplateMetadata
impl TemplateMetadata
Sourcepub fn new(generated_at: DateTime<Utc>) -> Self
pub fn new(generated_at: DateTime<Utc>) -> Self
Creates a new TemplateMetadata with the given timestamp.
§Arguments
generated_at- UTC timestamp when the template was generated
§Example
use torrust_tracker_deployer_lib::infrastructure::templating::metadata::TemplateMetadata;
use chrono::{TimeZone, Utc};
let timestamp = Utc.with_ymd_and_hms(2026, 1, 27, 14, 30, 0).unwrap();
let metadata = TemplateMetadata::new(timestamp);Sourcepub fn generated_at(&self) -> &DateTime<Utc>
pub fn generated_at(&self) -> &DateTime<Utc>
Returns the generation timestamp.
§Example
use torrust_tracker_deployer_lib::infrastructure::templating::metadata::TemplateMetadata;
use chrono::{TimeZone, Utc};
let timestamp = Utc.with_ymd_and_hms(2026, 1, 27, 14, 30, 0).unwrap();
let metadata = TemplateMetadata::new(timestamp);
assert_eq!(metadata.generated_at(), ×tamp);Sourcepub fn generated_at_iso8601(&self) -> String
pub fn generated_at_iso8601(&self) -> String
Returns the timestamp formatted as ISO 8601 string.
Format: YYYY-MM-DDTHH:MM:SSZ (e.g., 2026-01-27T14:30:00Z)
§Example
use torrust_tracker_deployer_lib::infrastructure::templating::metadata::TemplateMetadata;
use chrono::{TimeZone, Utc};
let timestamp = Utc.with_ymd_and_hms(2026, 1, 27, 14, 30, 0).unwrap();
let metadata = TemplateMetadata::new(timestamp);
assert_eq!(metadata.generated_at_iso8601(), "2026-01-27T14:30:00Z");Trait Implementations§
Source§impl Clone for TemplateMetadata
impl Clone for TemplateMetadata
Source§impl Debug for TemplateMetadata
impl Debug for TemplateMetadata
Source§impl<'de> Deserialize<'de> for TemplateMetadata
impl<'de> Deserialize<'de> for TemplateMetadata
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
impl Eq for TemplateMetadata
Source§impl PartialEq for TemplateMetadata
impl PartialEq for TemplateMetadata
Source§impl Serialize for TemplateMetadata
impl Serialize for TemplateMetadata
impl StructuralPartialEq for TemplateMetadata
Auto Trait Implementations§
impl Freeze for TemplateMetadata
impl RefUnwindSafe for TemplateMetadata
impl Send for TemplateMetadata
impl Sync for TemplateMetadata
impl Unpin for TemplateMetadata
impl UnsafeUnpin for TemplateMetadata
impl UnwindSafe for TemplateMetadata
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
Wrap the input message
T in a tonic::Request