Commit 7847eae
authored
Document ToXdr and FromXdr traits (#1767)
### What
Added documentation to the `ToXdr` and `FromXdr` traits explaining the
two-step serialization process: values are first converted to a `Val`,
then serialized to XDR in their `ScVal` form. Added `Errors` and
`Panics` sections to `FromXdr` and `from_xdr`, doc examples on both
traits, and doc comments on the `to_xdr`, `from_xdr` methods and the
`Error` associated type.
### Why
`FromXdr::from_xdr` panics if the provided bytes are not valid XDR for
an `ScVal`, but returns an error if the `Val` cannot be converted into
the target type. This distinction was undocumented. The panic originates
from the host side, making it non-obvious even when reading the
implementation.
Close #17661 parent c8cd59e commit 7847eae
1 file changed
+54
-4
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
29 | 29 | | |
30 | 30 | | |
31 | 31 | | |
32 | | - | |
| 32 | + | |
33 | 33 | | |
34 | | - | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
35 | 48 | | |
| 49 | + | |
36 | 50 | | |
37 | 51 | | |
38 | 52 | | |
39 | | - | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
40 | 76 | | |
41 | | - | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
42 | 80 | | |
| 81 | + | |
| 82 | + | |
43 | 83 | | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
44 | 94 | | |
45 | 95 | | |
46 | 96 | | |
| |||
0 commit comments