Description
Hey 👋
I've been perusing the git-ref
family of names, i.e. FullName
, FullNameRef
, and PartialNameRef
. I want to see if I'm using it right and also suggest a couple of additions that might be helpful for consumers of the API.
My use case is the following. I want to end up using try_find_reference
, which takes one parameter that is impl TryInto<PartialNameRef>
. I have a structural representation of the reference which looks like:
pub enum Remote {
Default,
Peer(PeerId),
}
pub struct Reference {
pub remote: Remote,
pub urn: Urn,
}
Now, I can't directly write a TryFrom
for PartialNameRef
as far as I can tell because of the associated lifetimes. But I can write a TryFrom
for FullName
and use to_partial
. I'm wondering if that's the correct and intended way of using the API?
Regarding my suggestions, when I wrote a TryFrom
for Remote
, I wasn't able to reuse this when writing TryFrom
for Reference
, since there's no way to join
two FullName
s. I ended up having to use format!
and use the TryFrom
instance on &String
. It would be useful to be able to join two names to get another valid name.
The other (possibly) useful suggestion would be to have a macro for writing static names, that are known to be valid at compile time. We used this technique in radicle-link[0] and it was extremely nice compare to using try_from
everywhere :)
Let me know what you think, and perhaps I could help contribute with these additions ✌️