You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It's cool that we can now access e["skb"].ip.version.v4 but there is no clean generic way of knowing if v4 or v6 should be accessed. We need to use something like hasattr.
In OVS is even more confusing because we do add the event_type in the JSON representation but that information is not available in the python side.
Maybe we could have a macro automagically add a helper called type() that returns a string representation of the enum variant, with the option to rewrite it like what serde does. Something like:
/// IP version and specific fields.
#[event_type]
#[serde(rename_all = "snake_case")]
pub enum SkbIpVersion {
#retis(rename = "ipv4")
V4 {
#[serde(flatten)]
v4: SkbIpv4Event,
},
#retis(rename = "ipv6")
V6 {
#[serde(flatten)]
v6: SkbIpv6Event,
},
}
That yields:
>>> e["skb"].ip.version.type()
"ipv4"
Of course this is just an idea for a follow up improvement.
It's cool that we can now access
e["skb"].ip.version.v4
but there is no clean generic way of knowing ifv4
orv6
should be accessed. We need to use something likehasattr
.In OVS is even more confusing because we do add the
event_type
in the JSON representation but that information is not available in the python side.Maybe we could have a macro automagically add a helper called
type()
that returns a string representation of the enum variant, with the option to rewrite it like whatserde
does. Something like:That yields:
Of course this is just an idea for a follow up improvement.
Originally posted by @amorenoz in #441 (comment)
The text was updated successfully, but these errors were encountered: