]> git.proxmox.com Git - rustc.git/blame - src/vendor/serde_derive/README.md
New upstream version 1.22.1+dfsg1
[rustc.git] / src / vendor / serde_derive / README.md
CommitLineData
3b2f2976
XL
1# Serde   [![Build Status]][travis] [![Latest Version]][crates.io]
2
3[Build Status]: https://api.travis-ci.org/serde-rs/serde.svg?branch=master
4[travis]: https://travis-ci.org/serde-rs/serde
5[Latest Version]: https://img.shields.io/crates/v/serde.svg
6[crates.io]: https://crates.io/crates/serde
7
8**Serde is a framework for *ser*ializing and *de*serializing Rust data structures efficiently and generically.**
9
10---
11
12You may be looking for:
13
14- [An overview of Serde](https://serde.rs/)
15- [Data formats supported by Serde](https://serde.rs/#data-formats)
16- [Setting up `#[derive(Serialize, Deserialize)]`](https://serde.rs/codegen.html)
17- [Examples](https://serde.rs/examples.html)
18- [API documentation](https://docs.serde.rs/serde/)
19- [Release notes](https://github.com/serde-rs/serde/releases)
20
21## Serde in action
22
23<a href="http://play.integer32.com/?gist=9003c5b88c1f4989941925d7190c6eec" target="_blank">
24<img align="right" width="50" src="https://raw.githubusercontent.com/serde-rs/serde-rs.github.io/master/img/run.png">
25</a>
26
27```rust
28#[macro_use]
29extern crate serde_derive;
30
31extern crate serde;
32extern crate serde_json;
33
34#[derive(Serialize, Deserialize, Debug)]
35struct Point {
36 x: i32,
37 y: i32,
38}
39
40fn main() {
41 let point = Point { x: 1, y: 2 };
42
43 // Convert the Point to a JSON string.
44 let serialized = serde_json::to_string(&point).unwrap();
45
46 // Prints serialized = {"x":1,"y":2}
47 println!("serialized = {}", serialized);
48
49 // Convert the JSON string back to a Point.
50 let deserialized: Point = serde_json::from_str(&serialized).unwrap();
51
52 // Prints deserialized = Point { x: 1, y: 2 }
53 println!("deserialized = {:?}", deserialized);
54}
55```
56
57## Getting help
58
59Serde developers live in the #serde channel on
60[`irc.mozilla.org`](https://wiki.mozilla.org/IRC). The #rust channel is also a
61good resource with generally faster response time but less specific knowledge
62about Serde. If IRC is not your thing or you don't get a good response, we are
63happy to respond to [GitHub issues](https://github.com/serde-rs/serde/issues/new)
64as well.
65
66## License
67
68Serde is licensed under either of
69
70 * Apache License, Version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or
71 http://www.apache.org/licenses/LICENSE-2.0)
72 * MIT license ([LICENSE-MIT](LICENSE-MIT) or
73 http://opensource.org/licenses/MIT)
74
75at your option.
76
77### Contribution
78
79Unless you explicitly state otherwise, any contribution intentionally submitted
80for inclusion in Serde by you, as defined in the Apache-2.0 license, shall be
81dual licensed as above, without any additional terms or conditions.