agronholm / agronholm/cbor2

Nesting custom tags

Open
#252 11 comments 0 reactions 0 assignees View on GitHub
enhancement
Dominant language
Rust
Stars
305
Forks
79
Avg merge
21h 59m
Merged PRs (30d)
2

Description

### Things to check first

- [x] I have searched the existing issues and didn't find my feature already requested there

### Feature description

I am working on a project where I'd like to be able to serialize nested custom tags, or collections of custom tags. I have been trying to understand from the documentation the best approach to use, especially if I'd also like to be able to use those tags separately. It feels like it should be possible now, but I can't feel out the right way to do it. I suspect it's just a documentation/user knowledge problem, so if there is an obvious way to do this that I am not understanding, I would be more than happy to take that lesson and write up a self-contained example and paragraph for a documentation PR.

### Use case

As an example, I have an `Interval` type which is a wrapper around a 2-tuple of floats, with operators defined for interval arithmetic. Separately, I have a `Vector[T]` type which is a generic numeric vector (similar to a numpy vector or glm, etc) - one common use case in my project is a `Vector[Interval]` - so while I've defined encoders and decoders that can be passed to `default` and `tag_hook` for the standalone types, I haven't found the right way to handle the case where `Vector` is a collection of `Interval`s (rather than `float` or `int`). Is there a way to do this that I am missing? Any pointers would be much appreciated!

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.