Skip to content

Commit

Permalink
Merge pull request scylladb#1024 from wprzytula/deser-derive-macros
Browse files Browse the repository at this point in the history
Deserialization derive macros
  • Loading branch information
Lorak-mmk authored Aug 6, 2024
2 parents 36d5edd + f470d1d commit bbb2874
Show file tree
Hide file tree
Showing 12 changed files with 5,076 additions and 1,436 deletions.
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

0 comments on commit bbb2874

Please sign in to comment.