zwire-serde (Bridge)
Optional serde serialization and deserialization bridge for zwire-protocol.
This crate keeps the core zwire Rust workspace 100% dependency-free while giving serde consumers:
to_wire(&value)/from_wire(&wire_value)converting anySerialize/Deserialize<'de>type to and fromWireValue(including zero-copy borrowed&str/Cow<str>fields and integer/boolean map keys), preservingzwire’s lossless±(2^53 - 1)integer string encoding fori64andu64.to_wire_json(&value)/from_wire_json(json)for direct canonical RFC-8259 JSON round-trips.SerdeWire<T>implementingWireCodec(plus fallibleSerdeWire::try_to_wire) soserde-derived structs and enums work directly withhydratable,sync_hydratable, andSyncBridge.#[serde(with = "zwire_serde::wire_value")]and#[serde(with = "zwire_serde::state_patch")]helpers for embeddingWireValueandStatePatchinsideserdetypes.
use serde::{Deserialize, Serialize};use zwire::prelude::*;use zwire_serde::{SerdeWire, from_wire, to_wire};
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, Default)]struct Profile { name: String, visits: u64,}
let scope = Scope::new();let profile = hydratable( &scope, "profile", SerdeWire::new(Profile { name: "Ada".into(), visits: 1_u64 << 60, }),);let wire = to_wire(&*scope.get(profile)).unwrap();assert_eq!(from_wire::<Profile>(&wire).unwrap(), *scope.get(profile));