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
book: adjust code examples to the new deserialization API
Examples in the Book are now adjusted to the new deserialization API,
and the book finally compile and the tests there pass.
Note that this commit does not describe exhaustively the intended way of
using the new deserialization framework; this is left for a follow-up.
Co-authored-by: Wojciech Przytuła <[email protected]>
To use this type in the driver, create a matching struct and derive:
12
12
-`SerializeValue`: in order to be able to use this struct in query parameters. \
13
-
This macro requires fields of UDT and struct to have matching names, but the order
14
-
of the fields is not required to be the same. \
15
-
Note: you can use different name using `rename` attribute - see `SerializeValue` macro documentation.
16
-
-`FromUserType`: in order to be able to use this struct in query results. \
17
-
This macro requires fields of UDT and struct to be in the same *ORDER*. \
18
-
This mismatch between `SerializeValue`and `FromUserType` requirements is a temporary situation - in the future `FromUserType` (or the macro that replaces it) will also require matching names.
13
+
-`DeserializeValue`: in order to be able to use this struct in query results. \
14
+
15
+
Both macros require fields of UDT and struct to have matching names, but the order
16
+
of the fields is not required to be the same. \
17
+
Note: you can use different name using `rename` attribute - see `SerializeValue`
18
+
and `DeserializeValue` macros documentation.
19
19
20
20
```rust
21
21
# externcrate scylla;
@@ -35,13 +35,9 @@ struct MyType {
35
35
```
36
36
37
37
> ***Important***\
38
-
> For deserialization, fields in the Rust struct must be defined in the same order as they are in the database.
39
-
> When receiving values, the driver will (de)serialize fields one after another, without looking at field names.
40
-
41
-
> ***Important***\
42
-
> For serialization, by default fields in the Rust struct must be defined with the same names as they are in the database.
43
-
> The driver will serialize the fields in the order defined by the UDT, matching Rust fields by name.
44
-
> You can change this behaviour using macro attributes, see `SerializeValue` macro documentation for more information.
38
+
> For (de)serialization, by default fields in the Rust struct must be defined with the same names as they are in the database.
39
+
> The driver will (de)serialize the fields in the order defined by the UDT, matching Rust fields by name.
40
+
> You can change this behaviour using macro attributes, see `SerializeValue`/`DeserializeValue` macro documentation for more information.
45
41
46
42
Now it can be sent and received just like any other CQL value:
47
43
```rust
@@ -51,10 +47,10 @@ Now it can be sent and received just like any other CQL value:
0 commit comments