-
Notifications
You must be signed in to change notification settings - Fork 110
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
scylla-macros: implement enforce_order flavor of SerializeCql
Some users might not need the additional robustness of `SerializeCql` that comes from sorting the fields before serializing, as they are used to the current behavior of `Value` and properly set the order of the fields in their Rust struct. In order to give them some performance boost, add an additional mode to `SerializeCql` called "enforce_order" which expects that the order of the fields in the struct is kept in sync with the DB definition of the UDT. It's still safe to use because, as the struct fields are serialized, their names are compared with the fields in the UDT definition order and serialization fails if the field name on some position is mismatched.
- Loading branch information
Showing
4 changed files
with
323 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,20 @@ | ||
use darling::FromMeta; | ||
|
||
pub(crate) mod cql; | ||
pub(crate) mod row; | ||
|
||
#[derive(Copy, Clone, PartialEq, Eq)] | ||
enum Flavor { | ||
MatchByName, | ||
EnforceOrder, | ||
} | ||
|
||
impl FromMeta for Flavor { | ||
fn from_string(value: &str) -> darling::Result<Self> { | ||
match value { | ||
"match_by_name" => Ok(Self::MatchByName), | ||
"enforce_order" => Ok(Self::EnforceOrder), | ||
_ => Err(darling::Error::unknown_value(value)), | ||
} | ||
} | ||
} |