зеркало из https://github.com/mozilla/gecko-dev.git
ba31bba005
MozReview-Commit-ID: 3kcDWGBPXt9 --HG-- rename : third_party/rust/proc-macro2/.cargo-checksum.json => third_party/rust/proc-macro2-0.3.6/.cargo-checksum.json rename : third_party/rust/proc-macro2/.travis.yml => third_party/rust/proc-macro2-0.3.6/.travis.yml rename : third_party/rust/proc-macro2/Cargo.toml => third_party/rust/proc-macro2-0.3.6/Cargo.toml rename : third_party/rust/proc-macro2/README.md => third_party/rust/proc-macro2-0.3.6/README.md rename : third_party/rust/proc-macro2/src/lib.rs => third_party/rust/proc-macro2-0.3.6/src/lib.rs rename : third_party/rust/proc-macro2/src/stable.rs => third_party/rust/proc-macro2-0.3.6/src/stable.rs rename : third_party/rust/proc-macro2/src/strnom.rs => third_party/rust/proc-macro2-0.3.6/src/strnom.rs rename : third_party/rust/proc-macro2/src/unstable.rs => third_party/rust/proc-macro2-0.3.6/src/unstable.rs rename : third_party/rust/proc-macro2/tests/test.rs => third_party/rust/proc-macro2-0.3.6/tests/test.rs rename : third_party/rust/quote/.cargo-checksum.json => third_party/rust/quote-0.5.2/.cargo-checksum.json rename : third_party/rust/quote/Cargo.toml => third_party/rust/quote-0.5.2/Cargo.toml rename : third_party/rust/quote/README.md => third_party/rust/quote-0.5.2/README.md rename : third_party/rust/quote/src/lib.rs => third_party/rust/quote-0.5.2/src/lib.rs rename : third_party/rust/quote/src/to_tokens.rs => third_party/rust/quote-0.5.2/src/to_tokens.rs rename : third_party/rust/quote/src/tokens.rs => third_party/rust/quote-0.5.2/src/tokens.rs rename : third_party/rust/quote/tests/test.rs => third_party/rust/quote-0.5.2/tests/test.rs rename : third_party/rust/syn/.cargo-checksum.json => third_party/rust/syn-0.13.1/.cargo-checksum.json rename : third_party/rust/syn/Cargo.toml => third_party/rust/syn-0.13.1/Cargo.toml rename : third_party/rust/syn/README.md => third_party/rust/syn-0.13.1/README.md rename : third_party/rust/syn/src/attr.rs => third_party/rust/syn-0.13.1/src/attr.rs rename : third_party/rust/syn/src/buffer.rs => third_party/rust/syn-0.13.1/src/buffer.rs rename : third_party/rust/syn/src/data.rs => third_party/rust/syn-0.13.1/src/data.rs rename : third_party/rust/syn/src/derive.rs => third_party/rust/syn-0.13.1/src/derive.rs rename : third_party/rust/syn/src/error.rs => third_party/rust/syn-0.13.1/src/error.rs rename : third_party/rust/syn/src/expr.rs => third_party/rust/syn-0.13.1/src/expr.rs rename : third_party/rust/syn/src/file.rs => third_party/rust/syn-0.13.1/src/file.rs rename : third_party/rust/syn/src/gen/fold.rs => third_party/rust/syn-0.13.1/src/gen/fold.rs rename : third_party/rust/syn/src/gen/visit.rs => third_party/rust/syn-0.13.1/src/gen/visit.rs rename : third_party/rust/syn/src/gen/visit_mut.rs => third_party/rust/syn-0.13.1/src/gen/visit_mut.rs rename : third_party/rust/syn/src/gen_helper.rs => third_party/rust/syn-0.13.1/src/gen_helper.rs rename : third_party/rust/syn/src/generics.rs => third_party/rust/syn-0.13.1/src/generics.rs rename : third_party/rust/syn/src/ident.rs => third_party/rust/syn-0.13.1/src/ident.rs rename : third_party/rust/syn/src/item.rs => third_party/rust/syn-0.13.1/src/item.rs rename : third_party/rust/syn/src/lib.rs => third_party/rust/syn-0.13.1/src/lib.rs rename : third_party/rust/syn/src/lifetime.rs => third_party/rust/syn-0.13.1/src/lifetime.rs rename : third_party/rust/syn/src/lit.rs => third_party/rust/syn-0.13.1/src/lit.rs rename : third_party/rust/syn/src/mac.rs => third_party/rust/syn-0.13.1/src/mac.rs rename : third_party/rust/syn/src/macros.rs => third_party/rust/syn-0.13.1/src/macros.rs rename : third_party/rust/syn/src/op.rs => third_party/rust/syn-0.13.1/src/op.rs rename : third_party/rust/syn/src/parse_quote.rs => third_party/rust/syn-0.13.1/src/parse_quote.rs rename : third_party/rust/syn/src/parsers.rs => third_party/rust/syn-0.13.1/src/parsers.rs rename : third_party/rust/syn/src/path.rs => third_party/rust/syn-0.13.1/src/path.rs rename : third_party/rust/syn/src/punctuated.rs => third_party/rust/syn-0.13.1/src/punctuated.rs rename : third_party/rust/syn/src/spanned.rs => third_party/rust/syn-0.13.1/src/spanned.rs rename : third_party/rust/syn/src/synom.rs => third_party/rust/syn-0.13.1/src/synom.rs rename : third_party/rust/syn/src/token.rs => third_party/rust/syn-0.13.1/src/token.rs rename : third_party/rust/syn/src/tt.rs => third_party/rust/syn-0.13.1/src/tt.rs rename : third_party/rust/syn/src/ty.rs => third_party/rust/syn-0.13.1/src/ty.rs extra : rebase_source : bda7c9d57b337b22b0cf8c095c4d3a79f4cd2682 |
||
---|---|---|
.. | ||
src | ||
.cargo-checksum.json | ||
Cargo.toml | ||
LICENSE-APACHE | ||
LICENSE-MIT | ||
README.md | ||
build.rs | ||
crates-io.md |
README.md
Serde
Serde is a framework for serializing and deserializing Rust data structures efficiently and generically.
You may be looking for:
- An overview of Serde
- Data formats supported by Serde
- Setting up
#[derive(Serialize, Deserialize)]
- Examples
- API documentation
- Release notes
Serde in action
Click to show Cargo.toml. Run this code in the playground.
[dependencies]
# The core APIs, including the Serialize and Deserialize traits. Always
# required when using Serde.
serde = "1.0"
# Support for #[derive(Serialize, Deserialize)]. Required if you want Serde
# to work for structs and enums defined in your crate.
serde_derive = "1.0"
# Each data format lives in its own crate; the sample code below uses JSON
# but you may be using a different one.
serde_json = "1.0"
#[macro_use]
extern crate serde_derive;
extern crate serde;
extern crate serde_json;
#[derive(Serialize, Deserialize, Debug)]
struct Point {
x: i32,
y: i32,
}
fn main() {
let point = Point { x: 1, y: 2 };
// Convert the Point to a JSON string.
let serialized = serde_json::to_string(&point).unwrap();
// Prints serialized = {"x":1,"y":2}
println!("serialized = {}", serialized);
// Convert the JSON string back to a Point.
let deserialized: Point = serde_json::from_str(&serialized).unwrap();
// Prints deserialized = Point { x: 1, y: 2 }
println!("deserialized = {:?}", deserialized);
}
Getting help
Serde developers live in the #serde channel on
irc.mozilla.org
. The #rust channel is also a
good resource with generally faster response time but less specific knowledge
about Serde. If IRC is not your thing or you don't get a good response, we are
happy to respond to GitHub issues
as well.
License
Serde is licensed under either of
- Apache License, Version 2.0, (LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0)
- MIT license (LICENSE-MIT or http://opensource.org/licenses/MIT)
at your option.
Contribution
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in Serde by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.