-
Notifications
You must be signed in to change notification settings - Fork 12
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
Return deserialize_bytes() in CidDeserializer::deserialize_any #21
Conversation
Thanks for the PR and the additional tests. I currently work on an |
I ported tests from ipld/serde_ipld_dagcbor#21 which show issues with the CID as enum approach.
I ported tests from ipld/serde_ipld_dagcbor#21 which show issues with the CID as enum approach. Run: cargo test --test de test_cid_in_tagged_enum
I've created #22, which also contains an explanation on why we current error on |
@sugyan I just saw the referenced PR from your repo. It looks like you need internally tagged and untagged enums a lot. I'll have a look if there might be a way to make this smoother and not having to implement it manually for all of them. |
@sugyan I had a closer look at Atrium. I want to find a solution that works for all use cases. It would be a shame if Atrium couldn't use this library as I really strive for having a common library for DAG-CBOR in Rust. I hope we'll find a solution, I really don't want that you'd need to use something custom or use a fork. |
@vmx Thank you for taking a look at ATrium. |
@vmx I see, it looks good to be able to switch the behavior with the feature flag like that. For my use case of ATrium, I'll be able to leave it with the default feature and it will work fine. |
#23 was merged. So you should be able to use it now. There will be one more change I'd like to make before cutting a new release (as it's a breaking one), but that should hopefully happen soon enough. |
This was fixed with the 0.5.0 release with the introduction of the |
When deserializing data containing
cid
as anenum
, there was no problem if it was Externally tagged, but an Error was returned when it was Internally tagged or Untagged.This seems to be because the
serde
will calldeserialize_any
in the Internally tagged/Untagged case. That causedCidDeserializer::deserialize_any
to return an Error when called.In reality, however,
CidDeserializer
is only used fromDeserializer::deserialize_cid
. I thought that when thisCidDeserializer
is used, the input that should be processed is the bytes of the cid, and there should be no problem processing it withdeserialize_bytes
. Returningself.deserialize_bytes(visitor)
does not affect the results of the existing tests.It is possible that I am not understanding this well enough, but is there any reason why I should return an Error here?