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

Change document controller type to OneOrSet #638

Merged
merged 8 commits into from
Feb 1, 2022
Merged

Conversation

cycraig
Copy link
Contributor

@cycraig cycraig commented Jan 31, 2022

Description of change

Allows multiple controllers to be set on a CoreDocument using a new generic OneOrSet collection, which wraps OrderedSet. OneOrSet is similar to OneOrMany except all entries are unique by key and is guaranteed to be non-empty.

This is to comply with the W3C DID specification:

The controller property is OPTIONAL. If present, the value MUST be a string or a set of strings that conform to the rules in § 3.1 DID Syntax.

This type change is backwards compatible since a single controller DID will deserialize to OneOrSetInner::One.

Changed

  • Change CoreDocument::controller() from Option<&CoreDID> to Option<&OneOrSet<CoreDID>.
  • Change CoreDocument::controller_mut() from Option<&mut CoreDID> to &mut Option<OneOrSet<CoreDID>>.

Added

  • Add OneOrSet collection.
  • Add IotaDocument::set_controller().

Links to any relevant issues

See issue #306.

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

Added new unit tests to ensure adding and removing document controllers is supported and works with diffs.

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

@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 31, 2022
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, thanks for the changes!

Copy link
Contributor

@olivereanderson olivereanderson left a comment

Choose a reason for hiding this comment

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

This is a nice improvement to the code base, but I think the associated from<U>(other: OneOrSet<U>) method should be refactored before this gets merged.

Copy link
Contributor

@olivereanderson olivereanderson left a comment

Choose a reason for hiding this comment

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

Thanks for the changes.

@cycraig cycraig merged commit 38c27a9 into dev Feb 1, 2022
@cycraig cycraig deleted the feat/controller-set branch February 1, 2022 12:27
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.

3 participants