// NOTE: This file should be kept in sync with README.md
use serde_derive::{Deserialize, Serialize}; use std::error::Error; use std::fs::File;
// Types annotated with `Serialize` can be stored as CBOR. // To be able to load them again add `Deserialize`. #[derive(Debug, Serialize, Deserialize)] struct Mascot {
name: String,
species: String,
year_of_birth: u32,
}
let ferris_file = File::create("examples/ferris.cbor")?; // Write Ferris to the given file. // Instead of a file you can use any type that implements `io::Write` // like a HTTP body, database connection etc.
serde_cbor::to_writer(ferris_file, &ferris)?;
let tux_file = File::open("examples/tux.cbor")?; // Load Tux from a file. // Serde CBOR performs roundtrip serialization meaning that // the data will not change in any way. let tux: Mascot = serde_cbor::from_reader(tux_file)?;
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.