Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[RFC] DidUri improvements #3

Open
dhuseby opened this issue Sep 25, 2019 · 4 comments
Open

[RFC] DidUri improvements #3

dhuseby opened this issue Sep 25, 2019 · 4 comments

Comments

@dhuseby
Copy link
Owner

dhuseby commented Sep 25, 2019

@mikelodder7 I like what you've done with DidUri so far. The validation is solid. However, I think we should create a trait called Did that has functions for accessing the parts of a DID string. Maybe even have traits for DidQuery and DidFragment and DidParams?

Here's why I want to make a Did trait. We can then have specific implementations for the different Did methods. I could impl Did for DidGit for instance and then I could also add functions that return libgit2 types along with the functions in the Did trait. The DidGit implementations for the DidQuery, DidFragment and DidParams also mean specialized things in the DidGit method context. The impl DidParams for DidGitParams will support the interface but also be able to return libgit2 references to specific commits in a repo and other things.

The current DidUri is a good first step, but I think making it a trait with specialized implementations for each DID method is in order.

Thoughts?

@dhuseby
Copy link
Owner Author

dhuseby commented Sep 25, 2019

Hrm...if we make the trait called DidUri instead of Did, then we can have a module level method that does the parsing and tries to create instances of the method-specific types that impl the DidUri trait. That way we could just do this:

// this will create an instance of DidGitUri
let git = Did::from_str("did:git:akjsdhgaksdjhgasdkgh").unwrap();

// this will create an instance of DidSovUri
let sov = Did::from_str("did:sov:akjsdhgaksdjhgasdkgh").unwrap();

That's what I'm thinking.

@mikelodder7
Copy link
Collaborator

My only concern is that all DIDs have a common format which is the goal of this function. After generic parsing, then you can downcast to the most specific ones, so I’m not sure what the trait buys.

@mikelodder7
Copy link
Collaborator

I’m not opposed to having a generic parse that returns the specific instance

@dhuseby
Copy link
Owner Author

dhuseby commented Sep 25, 2019

My only concern is that all DIDs have a common format which is the goal of this function. After generic parsing, then you can downcast to the most specific ones, so I’m not sure what the trait buys.

I guess that does make more sense. I'm mostly concerned with turning the method specific parts of the DID into instances of objects for that method. for instance, turning the commit hash in a did:git string into a commit object from libgit2.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants