agronholm / agronholm/cbor2

Nesting custom tags

未關閉
#252 11 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視
enhancement
主要語言
Rust
星號
305
分支
79
平均合併
21 小時 59 分鐘
30 天內合併 PR
2

描述

### 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!

貢獻指南

這個儲存庫沒有索引到貢獻指南

評估

這個 Issue 還沒有評估資料。

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。