Open pwfff opened 1 year ago
Name | Link |
---|---|
Latest commit | babc5b6291a19ed46c0d7337706a32938580c628 |
Latest deploy log | https://app.netlify.com/sites/cute-starship-2d9c9b/deploys/640e198e777fac0008cad2f2 |
Name | Link |
---|---|
Latest commit | babc5b6291a19ed46c0d7337706a32938580c628 |
Latest deploy log | https://app.netlify.com/sites/cute-starship-2d9c9b/deploys/640e198e777fac0008cad2f2 |
Oh, and this is re: https://github.com/jamesmunns/postcard/issues/95
Two standalone commits here:
An attempt at just making the field attribute a bit more terse, but I think this is basically just the 'wrapper' y'all had before? Still have to annotate every field, plus now I have to use
into()
everywhere. Diff for my project looks like this:A macro based on this post I found: https://users.rust-lang.org/t/proc-macro-attribute-to-add-a-serde-deserialize-with-to-every-field-in-a-struct/71231 This seems... fragile. I did find a serde issue/PR where they wanted to do something similar, but it's old, not very active, and had a lot of feedback I didn't quite grok. This does manage to achieve exactly what I was looking for though, so I have a copy in my own codebase that I'm proceeding with. Changes to my project look like this:
+#[all_fields_with("postcard::fixint::le")]
[derive(Serialize, Deserialize, Debug, Eq, PartialEq)]
pub struct RequestControllerCountResponse {
controller_count: u32, }
impl Handler for RequestControllerCount {
@@ -47,8 +48,8 @@ impl Handler for RequestControllerCount {
fn handle(&self, controller: &Controller) -> RequestControllerCountResponse { RequestControllerCountResponse {
There's probably a better way to make this stuff happen at the library level? Like ideally
use postcard::fixint::le::*
would just magically configure it for your whole module, but that magic is beyond me still :smiling_face_with_tear: