crypto: add PublicKey::to_namespace

Add a helper function for creating the `RefString`,
`refs/namespaces/<public key>`, for a given `PublicKey`.

Signed-off-by: Fintan Halpenny <fintan.halpenny@gmail.com>
X-Clacks-Overhead: GNU Terry Pratchett
This commit is contained in:
Fintan Halpenny 2023-03-30 15:51:40 +01:00
parent 91efbd9630
commit d73d485848
No known key found for this signature in database
GPG Key ID: 2552FB6F64066CB7
1 changed files with 5 additions and 0 deletions

View File

@ -361,6 +361,11 @@ impl PublicKey {
multibase::encode(multibase::Base::Base58Btc, buf)
}
#[cfg(feature = "git-ref-format")]
pub fn to_namespace(&self) -> git_ref_format::RefString {
git_ref_format::refname!("refs/namespaces").join(git_ref_format::Component::from(self))
}
}
impl FromStr for PublicKey {