-
Notifications
You must be signed in to change notification settings - Fork 363
Description
aws_lambda_events
is essentially a set of shadow schemas that are hand-maintained to match the event request/response types used by other services. This is very useful from a Rust perspective due to all the nice compile-time guarantees and performance optimizations we get using serde
. However, it is very much a moving target, where schemas are always adding new fields, not to mention frequently including undocumented fields.
It would be nice to have a usage mode for 'I want the bleeding edge, including unmodeled fields'. That way, consumers could both interact with undocumented fields that we will probably never model, as well as the latest and greatest new fields even before we release a new version.
We could do that today via a 'catch-all' serde-modeled field that just is represented as a Map<String, Value>
, as demonstrated here: serde-rs/serde#941 (comment)
#[derive(Serialize, Deserialize)]
struct S {
a: u32,
b: String,
#[serde(flatten)]
other: Map<String, Value>,
}
And then the caller can interact with contained fields at runtime, or just dump it to logs.
I think probably it belongs under a something like feature = "catch-all-fields"
since this will involve extra allocations and other overhead?
It would be a fair bit of gruntwork to implement everywhere, but probably a LLM could do it pretty easily.