Module soroban_sdk::serde
source · Expand description
Serialize and deserialize values to and from Bytes.
All types that are convertible to and from RawVal implement the Serialize and Deserialize traits, and serialize to the ScVal XDR form.
Examples
use soroban_sdk::{
serde::{Deserialize, Serialize},
Env, Bytes, IntoVal, TryFromVal,
};
let env = Env::default();
let value: u32 = 5;
let bytes = value.serialize(&env);
assert_eq!(bytes.len(), 8);
let roundtrip = u32::deserialize(&env, &bytes);
assert_eq!(roundtrip, Ok(value));
Traits
Implemented by types that can be deserialized from Bytes.