-
Notifications
You must be signed in to change notification settings - Fork 236
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
feat: deserialize requests #1351
Conversation
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.
lgtm, pending @DaniPopes
crates/json-rpc/src/request.rs
Outdated
// SAFETY: params is a ZST, so it's safe to fail to initialize it | ||
unsafe { | ||
params = Some(std::mem::transmute( | ||
MaybeUninit::<Params>::uninit().assume_init(), | ||
)) | ||
} |
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.
I believe this is sound, iirc this should also work
std::mem::zeroed::<T>()
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.
changed it to this and removed unnecessary transmute
meta: RequestMeta::new(method.unwrap(), id.unwrap_or(Id::None)), | ||
params: params.unwrap(), |
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.
these are fine, because checked above
@prestwich clippy does not like this -.- perhaps this works |
It's not UB if it's zero-sized, fixable by just allowing the lint and removing the transmute since that lint is valid |
|
* feat: deserialize requests * lint: clippy
Motivation
Deserialize request objects
Solution
PR Checklist