feat: check that the CidBuilder hasher is usable #91
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.
Ref: #90
When using
SetCidBuilder
you can set up for a hasher that will not be found when aSum()
is eventually called inEncodeProtobuf()
, and the error from this doesn't bubble up throughRawData()
, it just panics.So this change adds an error return to
SetCidBuilder()
and will fail to use the builder if it's going to result in that error. If the error isn't handled then you'll get a silent default to a (presumably) working builder. If it's checked then at least you'll have an error to bubble up to the user or some place helpful.However, the caveat here is that we are not actually testing
Sum()
will work, only the obvious path to the error. If we are given a customCidBuilder
that doesn't matchPrefix
, or if there is a customSum()
that doesn't useMhType
then this isn't going to work. But I'm not sure what that situation is.This is a soft option for dealing with #90.