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
This issue presents a potential enhancement to the EventKind enumeration within the review-database crate and proposes corresponding actions to address the identified needs.
At present, the serialized form of the EventKind enumeration is subject to potential alterations due to the automatic integer assignment performed by the Rust compiler during serialization. This could result in unintended changes to the serialized values of existing enumeration members when future modifications, such as the addition or deletion of members, occur.
To counter this potential problem, the proposal is to establish a stable serialized form for the EventKind enumeration. This can be accomplished by assigning a fixed serialized value to each enum member explicitly. By doing so, the serialized form of EventKind will remain stable, irrespective of future modifications to the enumeration. It's worth noting that the first enum member should be assigned 0 to maintain compatibility with the FromPrimitive trait. Here is a representative implementation:
#[derive(Serialize,Clone,Copy,Debug,Deserialize,Eq,FromPrimitive,PartialEq,ToPrimitive)]#[repr(u32)]#[allow(clippy::module_name_repetitions)]pubenumEventKind{DnsCovertChannel = 0,HttpThreat = 1,RdpBruteForce = 2,//... Continue for other enum members}
In addition, it is recommended that the EventKind enumeration is made non-exhaustive. By adding the #[non_exhaustive] attribute, future additions of new event kinds can be made without breaking existing code that matches on EventKind.
Here is the modified enum with the non-exhaustive attribute:
#[derive(Serialize,Clone,Copy,Debug,Deserialize,Eq,FromPrimitive,PartialEq,ToPrimitive)]#[repr(u32)]#[non_exhaustive]#[allow(clippy::module_name_repetitions)]pubenumEventKind{DnsCovertChannel = 0,HttpThreat = 1,RdpBruteForce = 2,//... Continue for other enum members}
The successful implementation of these changes would contribute significantly to the robustness and adaptability of the review-database crate, ensuring it remains stable in light of any future changes.
The text was updated successfully, but these errors were encountered:
This issue presents a potential enhancement to the
EventKind
enumeration within thereview-database
crate and proposes corresponding actions to address the identified needs.At present, the serialized form of the
EventKind
enumeration is subject to potential alterations due to the automatic integer assignment performed by the Rust compiler during serialization. This could result in unintended changes to the serialized values of existing enumeration members when future modifications, such as the addition or deletion of members, occur.To counter this potential problem, the proposal is to establish a stable serialized form for the
EventKind
enumeration. This can be accomplished by assigning a fixed serialized value to each enum member explicitly. By doing so, the serialized form ofEventKind
will remain stable, irrespective of future modifications to the enumeration. It's worth noting that the first enum member should be assigned 0 to maintain compatibility with theFromPrimitive
trait. Here is a representative implementation:In addition, it is recommended that the
EventKind
enumeration is made non-exhaustive. By adding the#[non_exhaustive]
attribute, future additions of new event kinds can be made without breaking existing code that matches onEventKind
.Here is the modified enum with the non-exhaustive attribute:
The successful implementation of these changes would contribute significantly to the robustness and adaptability of the
review-database
crate, ensuring it remains stable in light of any future changes.The text was updated successfully, but these errors were encountered: