Skip to content

Commit 35f1c58

Browse files
committed
book: update examples to use DeserializeValue
Also, no longer mention the limitations of old derive macros. The new macros have no limitations compared to Serialize macros.
1 parent cdcbad2 commit 35f1c58

File tree

2 files changed

+5
-6
lines changed

2 files changed

+5
-6
lines changed

docs/source/data-types/udt.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,14 @@ and `DeserializeValue` macros documentation.
2020
```rust
2121
# extern crate scylla;
2222
# async fn check_only_compiles() {
23-
use scylla::macros::{FromUserType, SerializeValue};
23+
use scylla::macros::{DeserializeValue, SerializeValue};
2424

2525
// Define a custom struct that matches the User Defined Type created earlier.
26-
// Fields must be in the same order as they are in the database and also
27-
// have the same names.
26+
// Fields don't have to be in the same order as they are in the database.
27+
// By default, they must have the same names, but this can be worked around
28+
// using `#[rename] field attribute.
2829
// Wrapping a field in Option will gracefully handle null field values.
29-
#[derive(Debug, FromUserType, SerializeValue)]
30+
#[derive(Debug, DeserializeValue, SerializeValue)]
3031
struct MyType {
3132
int_val: i32,
3233
text_val: Option<String>,

docs/source/migration-guides/0.11-serialization.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,6 @@ The driver comes a set of `impl`s of those traits which allow to represent any C
4242

4343
By default, the `SerializeRow` and `SerializeValue` **will match the fields in the Rust struct by name to bind marker names** (in case of `SerializeRow`) **or UDT field names** (in case of `SerializeValue`). This is different from the old `ValueList` and `IntoUserType` macros which did not look at the field names at all and would expect the user to order the fields correctly. While the new behavior is much more ergonomic, you might have reasons not to use it.
4444

45-
> **NOTE:** The deserialization macro counterparts `FromRow` and `FromUserType` have the same limitation as the old serialization macros - they require struct fields to be properly ordered. While a similar rework is planned for the deserialization traits in a future release, for the time being it might not be worth keeping the column names in sync with the database.
46-
4745
In order to bring the old behavior to the new macros (the only difference being type checking which cannot be disabled right now) you can configure it using attributes, as shown in the snippet below:
4846

4947
```rust

0 commit comments

Comments
 (0)