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

Rename MethodQuery to DIDUrlQuery, move OrderedSet, KeyComparable #634

Merged
merged 4 commits into from
Jan 31, 2022

Conversation

cycraig
Copy link
Contributor

@cycraig cycraig commented Jan 28, 2022

Description of change

House-keeping changes: moves the OrderedSet collection and associated KeyComparable trait from identity-did to identity-core. This also makes OrderedSet more generic by introducing the Queryable trait for DID-specific lookups.

Breaking change due to different import paths and the introduction of Queryable to handle the query/query_mut functions. Also renames MethodQuery to a more generic DIDUrlQuery, since I intend to use it for a future resolve_service function.

Changed

  • Move OrderedSet from identity-did to identity-core.
  • Move KeyComparable from identity-did to identity-core.
  • Rename MethodQuery to DIDUrlQuery and move its sub-package from /method to /utils.
  • Rename KeyComparable::as_key() to KeyComparable::key().

Added

  • Add Queryable trait.

Links to any relevant issues

Fixes #633.

Type of change

  • Bug fix (a non-breaking change which fixes an issue)
  • Enhancement (a non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation Fix

How the change has been tested

Unit tests and examples pass locally.

Change checklist

  • I have followed the contribution guidelines for this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes

Move OrderedSet from identity-did to identity-core.
Move KeyComparable from identity-did to identity-core.
Add Queryable trait.
@cycraig cycraig added Breaking change A change to the API that requires a major release. Part of "Changed" section in changelog Rust Related to the core Rust code. Becomes part of the Rust changelog. labels Jan 28, 2022
@cycraig
Copy link
Contributor Author

cycraig commented Jan 28, 2022

Not entirely happy with all changes, such as:

  1. the naming of DIDUrlQuery (still needs to be something that can apply to querying a service or verification method but it really only uses the fragment part of the relative URL).
  2. the naming of the identity-did/utils sub-module.
  3. the fact that the key-uniqueness of OrderedSet can be violated by query_mut: this is possible in the original code even without these changes through IotaDocument/CoreDocument::resolve_method_mut which use it. This is why collections like HashSet do not allow mutable iterators or accessors, to avoid this problem. To fix it would mean removing any function that returns a mutable reference into an OrderedSet, which would not be so bad in my opinion (the intended usage is through methods like OrderedSet::replace for modification) but would be a significant breaking change.

@cycraig cycraig marked this pull request as ready for review January 28, 2022 12:12
Copy link
Contributor

@PhilippGackstatter PhilippGackstatter left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me!

I guess a more general name for DidUrlQuery would be DidDocumentPropertyQuery but that's unwieldy, so the current name seems perfectly fine to me.

Regarding the mutability: While annoying that it is possible, it's unlikely to happen, as someone would have to change the CoreDIDUrl of a e.g. method in the OrderedSet, iiuc. The account also doesn't expose that except through update_document_unchecked, so it's well contained.

identity-did/src/utils/queryable.rs Outdated Show resolved Hide resolved
@cycraig cycraig merged commit 9350ea7 into dev Jan 31, 2022
@cycraig cycraig deleted the chore/move-collections branch January 31, 2022 07:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Breaking change A change to the API that requires a major release. Part of "Changed" section in changelog Rust Related to the core Rust code. Becomes part of the Rust changelog.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Task] Move KeyComparable, OrderedSet to identity-core
3 participants