Get the latest tech news
A Rust API Inspired by Python, Powered by Serde
Years ago, I worked on reimplementing some Python code in Rust and needed to adapt Python’s dynamic reflection capabilities (aka __getattr__) to the strict and …
Putting aside what WMI even is, this is the kind of thing Python is extraordinarily good at: A clear, concise, and intuitive interface abstracting over a complex and gnarly implementation. While simpler to do from the library’s point of view, this approach forces the user to manually implement the Queryable trait for each and every new type they want to use, which is verbose and error-prone and not really ergonomic, even without proper error handling or support for nested objects. This is far from the only way to do this: building a procedural macro is perhaps the more “classic” solution to this problem, and while for me the tradeoffs between maintainability, feature support, and ease of use still justify the use/abuse of Serde, I still think there’s room for a middle ground (perhaps like dtolnay’s reflect).
Or read this on Hacker News