Skip to content
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

Deserialization derive macros #1024

Merged
merged 29 commits into from
Aug 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
2acca75
macros/parser: use syn::Path, not TokenStream
wprzytula May 25, 2024
04f8c01
deserialize: pub-ify items for use in macros
wprzytula Jun 25, 2024
cc234cd
deserialize macros common helpers
wprzytula Jun 25, 2024
a1d37d2
DeserializeValue: unordered flavour support
wprzytula Jun 25, 2024
e324029
DeserializeValue: unordered flavour tests
wprzytula Jun 25, 2024
472badd
DeserializeValue: unordered flavour errors tests
wprzytula Jun 25, 2024
894414b
DeserializeRow: unordered flavour support
wprzytula Jun 25, 2024
01f1afd
DeserializeRow: unordered flavour tests
wprzytula Jun 25, 2024
f740d49
DeserializeRow: unordered flavour errors tests
wprzytula Jun 26, 2024
bab6db8
Deserialize{Value,Row}: support `rename` attribute
wprzytula Jun 25, 2024
a9ae38a
DeserializeValue: enforce_order flavour support
wprzytula Jun 25, 2024
8e10af6
DeserializeValue: enforce_order flavour tests
wprzytula Jun 25, 2024
cc0457b
DeserializeRow: enforce_order flavour support
wprzytula Jun 25, 2024
b1fa8eb
DeserializeRow: enforce_order flavour tests
wprzytula Jun 25, 2024
11d1a71
DeserializeRow: enforce_order flavour errors tests
wprzytula Jun 26, 2024
e09abc5
DeserializeValue: `skip_name_checks` flag support
wprzytula Jun 25, 2024
70c3615
DeserializeValue: `skip_name_checks` flag tests
wprzytula Jun 25, 2024
64ead02
DeserializeRow: `skip_name_checks` flag support
wprzytula Jun 25, 2024
597c62f
DeserializeRow: `skip_name_checks` flag tests
wprzytula Jun 25, 2024
623adc3
Deserialize{Value,Row}: attribute validation
wprzytula Jun 25, 2024
ddc08b5
DeserializeValue: `forbid_excess_udt_fields` flag support
wprzytula Jun 25, 2024
bc9814a
DeserializeValue: `forbid_excess_udt_fields` tests
wprzytula Jun 25, 2024
7083ed9
DeserializeValue: `allow_missing` attribute support
wprzytula Jun 25, 2024
2d76697
DeserializeValue: `allow_missing` usage validation
wprzytula Jun 25, 2024
e086dc4
DeserializeValue: `allow_missing` tests
wprzytula Jun 25, 2024
a85067a
DeserializeValue: `default_when_null` attribute support
wprzytula Jun 25, 2024
96155f1
DeserializeValue: `default_when_null` tests
wprzytula Jun 25, 2024
a970436
value: move tests to a separate file
wprzytula Jun 26, 2024
f470d1d
row: move tests to a separate file
wprzytula Jun 26, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 21 additions & 3 deletions scylla-cql/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ pub mod errors;
pub mod frame;
#[macro_use]
pub mod macros {
pub use scylla_macros::DeserializeRow;
pub use scylla_macros::DeserializeValue;
pub use scylla_macros::FromRow;
pub use scylla_macros::FromUserType;
pub use scylla_macros::IntoUserType;
Expand All @@ -27,12 +29,30 @@ pub mod _macro_internal {
pub use crate::frame::response::cql_to_rust::{
FromCqlVal, FromCqlValError, FromRow, FromRowError,
};
pub use crate::frame::response::result::{CqlValue, Row};
pub use crate::frame::response::result::{ColumnSpec, ColumnType, CqlValue, Row};
pub use crate::frame::value::{
LegacySerializedValues, SerializedResult, Value, ValueList, ValueTooBig,
};
pub use crate::macros::*;

pub use crate::types::deserialize::row::{
deser_error_replace_rust_name as row_deser_error_replace_rust_name,
mk_deser_err as mk_row_deser_err, mk_typck_err as mk_row_typck_err,
BuiltinDeserializationError as BuiltinRowDeserializationError,
BuiltinDeserializationErrorKind as BuiltinRowDeserializationErrorKind,
BuiltinTypeCheckErrorKind as DeserBuiltinRowTypeCheckErrorKind, ColumnIterator,
DeserializeRow,
};
pub use crate::types::deserialize::value::{
deser_error_replace_rust_name as value_deser_error_replace_rust_name,
mk_deser_err as mk_value_deser_err, mk_typck_err as mk_value_typck_err,
BuiltinDeserializationError as BuiltinTypeDeserializationError,
BuiltinDeserializationErrorKind as BuiltinTypeDeserializationErrorKind,
BuiltinTypeCheckErrorKind as DeserBuiltinTypeTypeCheckErrorKind, DeserializeValue,
UdtDeserializationErrorKind, UdtIterator,
UdtTypeCheckErrorKind as DeserUdtTypeCheckErrorKind,
};
pub use crate::types::deserialize::{DeserializationError, FrameSlice, TypeCheckError};
pub use crate::types::serialize::row::{
BuiltinSerializationError as BuiltinRowSerializationError,
BuiltinSerializationErrorKind as BuiltinRowSerializationErrorKind,
Expand All @@ -51,6 +71,4 @@ pub mod _macro_internal {
pub use crate::types::serialize::{
CellValueBuilder, CellWriter, RowWriter, SerializationError,
};

pub use crate::frame::response::result::ColumnType;
}
4 changes: 3 additions & 1 deletion scylla-cql/src/types/deserialize/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,9 @@ impl Display for DeserializationError {
// - BEFORE an error is cloned (because otherwise the Arc::get_mut fails).
macro_rules! make_error_replace_rust_name {
($fn_name: ident, $outer_err: ty, $inner_err: ty) => {
fn $fn_name<RustT>(mut err: $outer_err) -> $outer_err {
// Not part of the public API; used in derive macros.
#[doc(hidden)]
pub fn $fn_name<RustT>(mut err: $outer_err) -> $outer_err {
// Safety: the assumed usage of this function guarantees that the Arc has not yet been cloned.
let arc_mut = std::sync::Arc::get_mut(&mut err.0).unwrap();

Expand Down
Loading
Loading