Skip to content

Commit 9c1b7c3

Browse files
committed
Move TIME_FMT const into AllowedSigner impl
1 parent ef5b5ae commit 9c1b7c3

File tree

1 file changed

+15
-5
lines changed

1 file changed

+15
-5
lines changed

src/allowed_signers.rs

+15-5
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,6 @@ use std::{
1111
path::Path,
1212
};
1313

14-
/// The format string for time fields.
15-
const TIME_FMT: &str = "%Y%m%d%H%M%S";
16-
1714
/// A single entry in the allowed signers file.
1815
#[derive(Debug)]
1916
pub struct AllowedSigner {
@@ -23,15 +20,28 @@ pub struct AllowedSigner {
2320
pub key: SshPublicKey,
2421
}
2522

23+
impl AllowedSigner {
24+
/// The format string for timestamps.
25+
const TIMESTAMP_FMT: &'static str = "%Y%m%d%H%M%S";
26+
}
27+
2628
impl fmt::Display for AllowedSigner {
2729
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
2830
write!(f, "{}", self.principal)?;
2931

3032
if let Some(valid_after) = self.valid_after {
31-
write!(f, " valid-after={}", valid_after.format(TIME_FMT))?;
33+
write!(
34+
f,
35+
" valid-after={}",
36+
valid_after.format(Self::TIMESTAMP_FMT)
37+
)?;
3238
};
3339
if let Some(valid_before) = self.valid_before {
34-
write!(f, " valid-before={}", valid_before.format(TIME_FMT))?;
40+
write!(
41+
f,
42+
" valid-before={}",
43+
valid_before.format(Self::TIMESTAMP_FMT)
44+
)?;
3545
};
3646

3747
write!(f, " {}", self.key)

0 commit comments

Comments
 (0)