Skip to content
Unverified Commit 2f2e1438 authored by david-perez's avatar david-perez Committed by GitHub
Browse files

Fix serialization of required shapes (timestamps and nested shapes) (#1275)

In #1148, `@required` started being strictly interpreted by server SDKs.

That meant that when serializing values from structures, we no longer
borrow for every shape when looking into `Option`s as in:

```
if let Some(var_37) = &input.value
```

(See for example `RustWriter.serializeStructure` from
`JsonSerializerGenerator.kt` for the relevant serialization
code-generation routine)

Instead, we attempt to serialize the unborrowed required shape value.
This works well for booleans, numeric types (since they are `Copy`),
collections (since we borrow their items while iterating), and strings
(since we call `as_str()`). It also worked for unions and documents,
since we already borrowed (note that `ValueExpression.kt` makes sure to
not borrow twice if the value is already a reference, like when clients
look into `Option`s).

We fixed borrowing of blobs in #1269.

However, we currently don't borrow for timestamps and nested shapes.
This commit fixes that, and adds a comprehensive protocol test to ensure
we exercise all the lines relevant to serialization of required shapes.
parent 565d8383
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment