-
Notifications
You must be signed in to change notification settings - Fork 139
[WIP][derive] Support custom TryFromBytes validator #372
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
Open
joshlf
wants to merge
1
commit into
try-from-bytes-raw-argument-to-is-bit-valid--derive
Choose a base branch
from
try-from-bytes-raw-argument-to-is-bit-valid--derive-validator
base: try-from-bytes-raw-argument-to-is-bit-valid--derive
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
joshlf
commented
Sep 11, 2023
zerocopy-derive/src/lib.rs
Outdated
| return Ok(None); | ||
| }; | ||
| if let Some(attr) = attrs.next() { | ||
| return Err(Error::new_spanned(attr, "multiple attributes are unsupported")); |
Member
Author
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Change this to "multiple zerocopy attributes"
joshlf
commented
Sep 11, 2023
joshlf
commented
Sep 11, 2023
zerocopy-derive/src/lib.rs
Outdated
| // the compiler is worse at optimizing it? | ||
| let validate: fn(&Self) -> bool = Self::#validator; | ||
| // SAFETY: TODO | ||
| validate(unsafe { candidate.as_ref() }) |
Member
Author
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remember: This must be sound in the face of validate panicking.
5e660a4 to
6f2adbd
Compare
c2db8b1 to
342026f
Compare
6f2adbd to
d638597
Compare
342026f to
7286c44
Compare
d638597 to
bb5a5ae
Compare
7286c44 to
bff9a97
Compare
bb5a5ae to
98942f6
Compare
bff9a97 to
d463caf
Compare
98942f6 to
5b61210
Compare
d463caf to
90c2aed
Compare
5b61210 to
8e079ad
Compare
90c2aed to
7707fb1
Compare
8e079ad to
1083475
Compare
7707fb1 to
de82f0e
Compare
1083475 to
d838a87
Compare
de82f0e to
575c570
Compare
d838a87 to
85d0bcb
Compare
575c570 to
ceb1983
Compare
85d0bcb to
c068ed5
Compare
ceb1983 to
98ca637
Compare
c068ed5 to
f52abdf
Compare
98ca637 to
8eff3b0
Compare
f52abdf to
c816899
Compare
8eff3b0 to
4004cbe
Compare
c816899 to
9bfd4fa
Compare
8595f94 to
843e2ee
Compare
9bfd4fa to
38e9af7
Compare
843e2ee to
a46bdc1
Compare
38e9af7 to
ac566bc
Compare
a46bdc1 to
e1cd6a7
Compare
ac566bc to
3bda0f4
Compare
e1cd6a7 to
55aee47
Compare
3bda0f4 to
3c385c8
Compare
55aee47 to
e250332
Compare
3c385c8 to
a093d6f
Compare
e250332 to
aeea5f2
Compare
a093d6f to
f262f98
Compare
aeea5f2 to
5c45ea8
Compare
f262f98 to
6de1129
Compare
5c45ea8 to
3271ca4
Compare
6de1129 to
d19a443
Compare
3271ca4 to
5737178
Compare
d19a443 to
3dd3531
Compare
5737178 to
1439d4b
Compare
3dd3531 to
77ef559
Compare
1439d4b to
fe3118f
Compare
TODO:
- Cleaner way to pass name of validator to `impl_block`?
- Cleaner way to parse validator attribute?
- Safety comment in emitted call to `validate`
- Tests (especially including tests for the error message resulting from
passing a validator with the wrong type signature - test for both
argument types and return types)
- Also test for invalid zerocopy attributes
- Also test for hygiene - that the validator can't access variables
from the `is_bit_valid` function body scope
- Other misc TODO comments in code
77ef559 to
9e01587
Compare
fe3118f to
1f8ff06
Compare
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
TODO:
impl_block?validate