Add README and examples
This commit is contained in:
@@ -0,0 +1,30 @@
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
#[derive(Debug, PartialEq, Serialize, Deserialize)]
|
||||
struct ServiceConfig {
|
||||
name: String,
|
||||
enabled: bool,
|
||||
retries: i64,
|
||||
endpoints: Vec<String>,
|
||||
}
|
||||
|
||||
fn main() -> wson::Result<()> {
|
||||
let value = ServiceConfig {
|
||||
name: "worker".to_string(),
|
||||
enabled: true,
|
||||
retries: 3,
|
||||
endpoints: vec![
|
||||
"https://a.example".to_string(),
|
||||
"https://b.example".to_string(),
|
||||
],
|
||||
};
|
||||
|
||||
let text = wson::to_string(&value)?;
|
||||
println!("text: {text}");
|
||||
|
||||
let decoded: ServiceConfig = wson::from_str(&text)?;
|
||||
assert_eq!(decoded, value);
|
||||
println!("round trip ok");
|
||||
|
||||
Ok(())
|
||||
}
|
||||
Reference in New Issue
Block a user