Skip to content

Rust data structures for the Serde data model

License

Apache-2.0, MIT licenses found

Licenses found

Apache-2.0
LICENSE-APACHE
MIT
LICENSE-MIT
Notifications You must be signed in to change notification settings

rushmorem/serde-content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

34 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Serde data model

serde-content is an alternative design for the private Serde content types like this one. These types are used to store the Rust values that represent the Serde data model. The model is stable and well documented.

This crate offers a unified design for both serialising and deserialising data. The goal is to offer a stable interface with roundtrip guarantees when serialising to and deserialising from Value using our Serializer and Deserializer.

Example

use serde::{Deserialize, Serialize};
use serde_content::{Deserializer, Serializer};

#[derive(Debug, Serialize, Deserialize)]
struct Point {
    x: i32,
    y: i32,
}

fn main() -> serde_content::Result<()> {
    let point = Point { x: 1, y: 2 };

    // Convert the Point to the Value type.
    let serialized = Serializer::new().serialize(&point)?;

    // Pretty print the serialised Value.
    dbg!(&serialized);

    // Convert the Value back to a Point.
    let deserialized: Point = Deserializer::new(serialized).deserialize()?;

    // Pretty print the deserialised Point.
    dbg!(deserialized);

    Ok(())
}

License

Licensed under either of Apache License, Version 2.0 or MIT license at your option.
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.

About

Rust data structures for the Serde data model

Resources

License

Apache-2.0, MIT licenses found

Licenses found

Apache-2.0
LICENSE-APACHE
MIT
LICENSE-MIT

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages