Skip to content

Commit 1f3d326

Browse files
committed
Add doc comment with example to AllowedSigner
1 parent 9c1b7c3 commit 1f3d326

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

src/allowed_signers.rs

+16
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,22 @@ impl AllowedSigner {
2626
}
2727

2828
impl fmt::Display for AllowedSigner {
29+
/// Display the allowed signer in the format expected by the `allowed_signers` file.
30+
///
31+
/// # Examples
32+
/// ```
33+
/// # use hanko::AllowedSigner;
34+
/// # use chrono::{TimeZone, Local};
35+
/// let signer = AllowedSigner {
36+
/// principal: "cwoods@universal.exports".to_string(),
37+
/// valid_after: None,
38+
/// valid_before: Some(Local.with_ymd_and_hms(2030, 1, 1, 0, 0, 0).unwrap()),
39+
/// key: "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIJHDGMF+tZQL3dcr1arPst+YP8v33Is0kAJVvyTKrxMw"
40+
/// .parse()
41+
/// .unwrap(),
42+
/// };
43+
/// assert_eq!(signer.to_string(), "cwoods@universal.exports valid-before=20300101000000 ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIJHDGMF+tZQL3dcr1arPst+YP8v33Is0kAJVvyTKrxMw");
44+
/// ```
2945
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
3046
write!(f, "{}", self.principal)?;
3147

0 commit comments

Comments
 (0)