runar-serializer
Typed values with optional, selective field encryption for Runar apps and
services. Provides a compact, clone-efficient ArcValue container and
pluggable encryption via a SerializationContext (network/profile keys).
Install
[]
= "0.1"
Highlights
- ArcValue: typed, clone-efficient container with JSON/CBOR/Proto support
- Pluggable crypto: transparent encryption/decryption when a
SerializationContextis provided - Derives: works with
runar-serializer-macros(Encrypt,Plain)
Quick start
use ;
let av = new_struct;
assert_eq!;
// No encryption
let bytes = av.serialize?;
let roundtrip = deserialize?;
let user: Arc = roundtrip.as_struct_ref?;
Field‑level encryption (abridged)
Combine this crate with runar-serializer-macros and runar-keys to encrypt
specific fields for user/profile or system/network contexts.
use HashMap;
use Arc;
use ;
use ;
use ;
use Encrypt;
// Prepare keystores and resolver
let logger = new;
let mut network_master = new?;
let network_id = network_master.generate_network_data_key?;
let network_pub = network_master.get_network_public_key?;
let mut user_mobile = new?;
user_mobile.initialize_user_root_key?;
let profile_pk = user_mobile.derive_user_profile_key?;
user_mobile.install_network_public_key?;
let mut node = new?;
let token = node.generate_csr?;
let nk_msg = network_master.create_network_key_message?;
node.install_network_key?;
let resolver = new;
let mobile_ks = new as ;
let node_ks = new as ;
let profile = Profile ;
// Encrypt to generated EncryptedProfile
let enc: EncryptedProfile = profile.encrypt_with_keystore?;
// Decrypt in different contexts
let _mobile_view = enc.decrypt_with_keystore?; // user fields available
let _node_view = enc.decrypt_with_keystore?; // system fields available
// ArcValue integration with transparent encryption on serialize
let ctx = SerializationContext ;
let av = new_struct;
let ser = av.serialize?; // encrypted
let de = deserialize?; // decrypted for node
Plain derive (zero glue)
Use #[derive(Plain)] from runar-serializer-macros to implement efficient
conversions to/from ArcValue.
use ArcValue;
use Plain;
let av = new_struct;
let extracted: Arc = av.as_struct_ref?;
License
MIT. See LICENSE.