mirror of https://git.sr.ht/~stygianentity/bincode
Document some encoding details
Also, update Cargo.toml with my name.
This commit is contained in:
parent
bfbaeaacd1
commit
0be3c68164
|
|
@ -1,7 +1,7 @@
|
|||
[package]
|
||||
name = "bincode"
|
||||
version = "0.0.4"
|
||||
authors = ["Ty Overby <ty@pre-alpha.com>"]
|
||||
authors = ["Ty Overby <ty@pre-alpha.com>", "Francesco Mazzoli <f@mazzo.li>"]
|
||||
|
||||
repository = "https://github.com/TyOverby/bincode"
|
||||
documentation = "http://tyoverby.github.io/bincode/bincode/"
|
||||
|
|
|
|||
17
README.md
17
README.md
|
|
@ -49,3 +49,20 @@ fn main() {
|
|||
}
|
||||
|
||||
```
|
||||
|
||||
|
||||
## Details
|
||||
|
||||
The encoding (and thus decoding) proceeds unsurprisingly -- primitive
|
||||
types are encoded according to the underlying `Writer`, tuples and
|
||||
structs are encoded by encoding their fields one-by-one, and enums are
|
||||
encoded by first writing out the tag representing the variant and
|
||||
then the contents.
|
||||
|
||||
However, there are some implementation details to be aware of:
|
||||
|
||||
* `int`/`uint` are encoded as `i64`/`u64`, for portability.
|
||||
* enums variants are encoded as a `u32` instead that as a `uint`.
|
||||
`u32` is enough for all practical uses.
|
||||
* `str` is encoded as `(u64, &[u8])`, where the `u64` is the number of
|
||||
bytes contained in the encoded string.
|
||||
|
|
|
|||
Loading…
Reference in New Issue