Add README and examples

This commit is contained in:
2026-09-05 23:30:06 +00:00
parent d4b77ddcb9
commit 51b6c635d7
4 changed files with 206 additions and 0 deletions
+31
View File
@@ -0,0 +1,31 @@
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 bytes = wson::to_vec(&value)?;
println!("jbon length: {} bytes", bytes.len());
println!("jbon prefix: {:02x?}", &bytes[..bytes.len().min(16)]);
let decoded: ServiceConfig = wson::from_slice(&bytes)?;
assert_eq!(decoded, value);
println!("round trip ok");
Ok(())
}