paritytech / paritytech/parity-scale-codec
Implement support for `Box<[T]>` and `Arc<[T]>`
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 287
- Forks
- 103
- Avg merge
- 6d 13h
- Merged PRs (30d)
- 1
Description
Arc<[T]> is especially helpful in cases where something needs to be sent into a different thread, but cloning and double indirection are undesirable.
Right now both fail something like this:
error[E0277]: the trait bound `[subspace_core_primitives::pieces::PieceIndex]: parity_scale_codec::WrapperTypeDecode` is not satisfied
--> crates/subspace-networking/src/protocols/request_response/handlers/cached_piece_by_index.rs:28:24
|
28 | pub cached_pieces: Box<[PieceIndex]>,
| ^^^^^^^^^^^^^^^^^ the trait `parity_scale_codec::WrapperTypeDecode` is not implemented for `[subspace_core_primitives::pieces::PieceIndex]`, which is required by `std::boxed::Box<[subspace_core_primitives::pieces::PieceIndex]>: parity_scale_codec::Decode`
|
= help: the following other types implement trait `parity_scale_codec::WrapperTypeDecode`:
std::boxed::Box<T>
std::rc::Rc<T>
std::sync::Arc<T>
= note: required for `[subspace_core_primitives::pieces::PieceIndex]` to implement `parity_scale_codec::Decode`
= note: 1 redundant requirement hidden
= note: required for `std::boxed::Box<[subspace_core_primitives::pieces::PieceIndex]>` to implement `parity_scale_codec::Decode`
I'm not 100% sure, but suspect it is an upstream issue since downstream users will not be able to implement WrapperTypeDecode for Box<[T]> or Arc<[T]>.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the parity_scale_codec::WrapperTypeDecode trait and the Box/Arc decoding behavior implicated by the error in crates/subspace-networking/src/protocols/request_response/handlers/cached_piece_by_index.rs. Reproduce that example, then verify that Box and Arc support the requested decoding cases and that the existing codec checks still pass.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- backend
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100