-
Notifications
You must be signed in to change notification settings - Fork 516
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
add support for const length arrays ([u8; N]
)
#782
base: master
Are you sure you want to change the base?
Conversation
the problem is that there is no way to express that in protobuf. |
it seems pretty reasonable to me to encode a fixed length field as variable length in the proto, and to fail on the decoding of a mismatched length, as one would with any other invalid or unmatched message / field (though this PR does not yet have that behaviour).
this addresses an issue with |
Alright, but that behaviour is the key point, in my opinion. |
[u8; N]
)[u8; N]
)
updated PR to propagate errors, expose |
make BytesAdapter externally implementable, propagate errors from BytesAdapter decode fn
086fdbd
to
753aa7a
Compare
[u8; N]
)[u8; N]
)
minimal addition to implement
prost::encode::BytesAdapter
over[u8; N]
(alongsideVec<u8>
andBytes<u8>
.BytesAdapter
to be externally implementable (should make add encoding support for heapless::{Vec<u8>,String} #730 and other external bytes types possible)BytesAdapter
impl for[u8; N]
(note this only works with N<=32 due to Use const generics for arrayDefault
impl rust-lang/rust#61415, could mitigate this by exposingNewable
workaround)BytesAdapter
in case of a length mismatch for const types