Expand description
Lightweight and easy to use serialization, deserialization.
Provides abstract serialization into specific formats. Additionally provides the functionality to save and load the serialized content directly from and to disk.
To implement more data formats see: Serializer, Deserializer
§Examples
use proc_contra::{Serialize, Deserialize};
use lib_contra::{error::SuccessResult, position::Position, persistent::Persistent};
#[derive(Serialize, Deserialize)]
struct Point {
x: f32,
y: f32,
z: f32
}
fn modify_point() -> Result<(), Box<dyn std::error::Error>> {
let mut p = Point::load("path/to/point.json")?;
assert_eq!(p.x, 1.0f32);
p.x = 2.0f32;
p.save("path/to/point.json")?;
Ok(())
}
Re-exports§
pub use lib_contra;
Modules§
Traits§
- Deserialize
- Implementors of this trait can be deserialized from any format
- From
Json - Into
Json - Serialize
- Allows for the serialization of the implemented type
Derive Macros§
- Deserialize
- Derives the Deserialize trait implementation
- Serialize
- Derives the Serialize trait implementation