From d73d48584846f445c60c7370a15f7dd89ba2801e Mon Sep 17 00:00:00 2001 From: Fintan Halpenny Date: Thu, 30 Mar 2023 15:51:40 +0100 Subject: [PATCH] crypto: add PublicKey::to_namespace Add a helper function for creating the `RefString`, `refs/namespaces/`, for a given `PublicKey`. Signed-off-by: Fintan Halpenny X-Clacks-Overhead: GNU Terry Pratchett --- radicle-crypto/src/lib.rs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/radicle-crypto/src/lib.rs b/radicle-crypto/src/lib.rs index d050c757..3bb06988 100644 --- a/radicle-crypto/src/lib.rs +++ b/radicle-crypto/src/lib.rs @@ -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 {