Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Builder refactoring
Remove extra alias indirection
ServiceTypeAlias
- all its usage (2 places) fits on one screenRemove
add_service_types
in favor ofadd_service_type
. The removed function was only used once and easily replacable by its "singular" versionRemove
ServiceBuilderWithServiceType
- ServiceType is in fact optional, as https://sovrin-foundation.github.io/sovrin/spec/did-method-spec-template.html says:So requiring user to call one of the (originally 2 methods) is just not right. If we were to be just "opinionated" to require users of our builder to do so, it should follow same pattern as other required attributes such as
id
,service_endpoint
,extra
.If
add_service_type
is called with the same value as been provided before, throwInvalidInput
instead of quietly doing nothingIf
add_service_type
is called with empty string, throwInvalidInput
errorNote:
Probably stating obvious, but I take it that
ServiceBuilder
was somewhat of a shortcut as we didn't intend to use builder macro libraries at the time, and building full blown state pattern builder by hand is cumbersome (hence why required attributes are part ofServiceBuilder<E>::new(....)
constructor directly. Perhaps down the line we can adopt the same builder library as in messages crate.Additional
Squashed some additional tweak, don't want create crate X pull requests so I'll squash further smaller improvements here.
Debug
forDid
so it printsDid { did: "did:foo:bar", method: Some("foo"), id: "bar" }
instead of previouslyDid { did: "did:foo:bar", method: Some(4..7), id: 8..11 }
Display
forDidDocument
which prints the ddo as json