-
-
Notifications
You must be signed in to change notification settings - Fork 796
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
Deserializing runtime types #2609
Comments
You can try to do it in two steps. If I understood the problem correctly, you can try to Implement |
@Rulexec Unfortunately that doesn't address my issue.
struct Foo {
my_member: i32,
} The same type could instead be represented as: let foo = MyStructRepr {
name: "Foo".to_string(),
members: vec![("my_member".to_string(), Kind::Number)]
}; The point here is that the definition of the type is not available at compile time, as these are dynamic types created at runtime. I cannot use A similar thing was discussed in #2043, but unfortunately the solution there doesn't help my use case. |
This looks like The |
Yes, that is what I'm trying to achieve. |
I'm trying to implement a similar workflow for postcard and am also running into |
Unlike #2218, removing the |
That's not something that can be done without a huge amount of churn. We have no plans to do so |
Sorry if this is not the right place to ask, but I've been stuck with this problem for a while and I'm not sure if it's possible to achieve this using Serde.
I have what is effectively a dynamic (runtime) representation of a struct. I want to use this representation to deserialize some data. To my understanding, the typical solution would be to treat it as a map and use
deserialize_map
alongside a customVisitor
, however I cannot do that as the serialization format I'm using has length-prefixed maps. The data I'm interested in deserializing does not treat these types as maps, and so there's no length prefix. Althoughserialize_struct
is pretty much what I want, I can't use that either as the names of the members are not&'static str
.More concretely, here's a condensed example:
Is this doable with Serde?
The text was updated successfully, but these errors were encountered: