Skip to content
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

Allow custom derive for server_fns with custom encoding #2544

Closed
luxalpa opened this issue Apr 20, 2024 · 3 comments
Closed

Allow custom derive for server_fns with custom encoding #2544

luxalpa opened this issue Apr 20, 2024 · 3 comments

Comments

@luxalpa
Copy link
Contributor

luxalpa commented Apr 20, 2024

Is your feature request related to a problem? Please describe.
I want to have my server functions use bitcode encoding. For this I can implement IntoReq, FromReq, etc, but I noticed that the ServerFnInputType will always be #[derive(Clone, serde::Serialize, serde::Deserialize)] whereas I don't have a use for serde in this case and I actually want #[derive(Clone, bitcode::Encode, bitcode::Decode)] instead.

Describe the solution you'd like
have the server macro support parameters input_derive and output_derive

@gbj
Copy link
Collaborator

gbj commented Apr 20, 2024

Seems reasonable. Any interest in making a PR?

These parameters would just feed into the logic here

let (path, derives) = match input_ident.as_deref() {
Some("Rkyv") => (
PathInfo::Rkyv,
quote! {
Clone, #server_fn_path::rkyv::Archive, #server_fn_path::rkyv::Serialize, #server_fn_path::rkyv::Deserialize
},
),
Some("MultipartFormData")
| Some("Streaming")
| Some("StreamingText") => (PathInfo::None, quote! {}),
Some("SerdeLite") => (
PathInfo::Serde,
quote! {
Clone, #server_fn_path::serde_lite::Serialize, #server_fn_path::serde_lite::Deserialize
},
),
_ => (
PathInfo::Serde,
quote! {
Clone, #server_fn_path::serde::Serialize, #server_fn_path::serde::Deserialize
},
),
};

@luxalpa
Copy link
Contributor Author

luxalpa commented Apr 20, 2024

Yes, I will make one. Just need to figure out why the scenario differs so much for the output type.

@luxalpa
Copy link
Contributor Author

luxalpa commented Apr 20, 2024

PR: #2545

@gbj gbj closed this as completed May 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants