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
Copy file name to clipboardExpand all lines: mdbook/src/chapter_4/chapter_4_5.md
+13-25Lines changed: 13 additions & 25 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -17,33 +17,21 @@ struct YourStruct { .. }
17
17
18
18
## The `ExchangeData` trait
19
19
20
-
The `ExchangeData` trait is more complicated, and is established in the `communication/` module. There are two options for this trait, which are determined by whether you use the `--bincode` feature at compilation, or not.
20
+
The `ExchangeData` trait is more complicated, and is established in the `communication/` module. The trait is a synonym for
21
21
22
-
* If you use `--bincode` then the trait is a synonym for
where `serde` is Rust's most popular serialization and deserialization crate. A great many types implement these traits. If your types does not, you should add these decorators to their definition:
29
-
30
-
```rust,ignore
31
-
#[derive(Serialize, Deserialize)]
32
-
```
33
-
34
-
You must include the `serde` crate, and if not on Rust 2018 the `serde_derive` crate.
35
-
36
-
The downside to the `--bincode` flag is that deserialization will always involve a clone of the data, which has the potential to adversely impact performance. For example, if you have structures that contain lots of strings, timely dataflow will create allocations for each string even if you do not plan to use all of them.
* If you do not use the `--bincode` feature, then the `Serialize` and `Deserialize` requirements are replaced by `Abomonation`, from the `abomonation` crate. This trait allows in-place deserialization, but is implemented for fewer types, and has the potential to be a bit scarier (due to in-place pointer correction).
26
+
where `serde` is Rust's most popular serialization and deserialization crate. A great many types implement these traits. If your types does not, you should add these decorators to their definition:
39
27
40
-
Your types likely do not implement `Abomonation` by default, but you can similarly use
28
+
```rust,ignore
29
+
#[derive(Serialize, Deserialize)]
30
+
```
41
31
42
-
```rust,ignore
43
-
#[derive(Abomonation)]
44
-
```
32
+
You must include the `serde` crate, and if not on Rust 2018 the `serde_derive` crate.
45
33
46
-
You must include the `abomonation` and `abomonation_derive` crate for this to work correctly.
34
+
The downside to is that deserialization will always involve a clone of the data, which has the potential to adversely impact performance. For example, if you have structures that contain lots of strings, timely dataflow will create allocations for each string even if you do not plan to use all of them.
47
35
48
36
## An example
49
37
@@ -140,7 +128,7 @@ impl<D> TreeNode<D> {
140
128
141
129
We get a new error. A not especially helpful error. It says that it cannot find an `exchange` method, or more specifically that one exists but it doesn't apply to our type at hand. This is because the data need to satisfy the `ExchangeData` trait but do not. It would be better if this were clearer in the error messages, I agree.
142
130
143
-
We can fix the problem two ways. First, if you would like to use `bincode`, then we update the source like so:
131
+
The fix is to update the source like so:
144
132
145
133
```rust,ignore
146
134
#[macro_use]
@@ -154,10 +142,10 @@ struct TreeNode<D> {
154
142
}
155
143
```
156
144
157
-
and make sure to include the `serde_derive` and `serde` crates. Now when we run things (notice the `--features` flag) we see:
145
+
and make sure to include the `serde_derive` and `serde` crates.
158
146
159
147
```ignore
160
-
Echidnatron% cargo run --example types --features bincode
148
+
Echidnatron% cargo run --example types
161
149
Finished dev [unoptimized + debuginfo] target(s) in 0.07s
0 commit comments