ssh-encoding: add derive feature + extend derive functionallity #348
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I wanted to be able to derive
Encode
andDecode
for various message types in RFC 4253 and related RFCs. As the current implementation has some limitations (and I wanted to get some more macro-writing practice), I've gone ahead and extendedssh-derive
quite a bit. The result is a rather substantial refactor, but it now supports all types of structs as well as enums. I realize this might be a bit much to review, but seeing asssh-derive
is0.0.1-alpha
I figured it might be alright.This PR is really in two parts (let me know if it is better merged as two separate things):
ssh-derive
:Encode
/Decode
on all kinds of structs and enums.#[ssh(length_prefixed)]
to use length prefixing when encoding/decoding. Can be applies to the struct/enum itself, or to individual fields.#[repr(u8)]
and friends: Enum discriminants will encode/decode with the type specified by therepr
attribute.ssh-encoding
:derive
feature that re-exports the derive macros fromssh-derive
.ssh_encoding::Error
to handle unexpected discriminant values when decoding.derive
feature.