Module soroban_sdk::xdr

source ·
Expand description

Convert values to and from Bytes.

All types that are convertible to and from RawVal implement the ToXdr and FromXdr traits, and serialize to the ScVal XDR form.

Examples

use soroban_sdk::{
    xdr::{FromXdr, ToXdr},
    Env, Bytes, IntoVal, TryFromVal,
};

let env = Env::default();

let value: u32 = 5;

let bytes = value.to_xdr(&env);
assert_eq!(bytes.len(), 8);

let roundtrip = u32::from_xdr(&env, &bytes);
assert_eq!(roundtrip, Ok(value));

Modules

Structs

Enums

Constants

Traits

  • Discriminant defines types that may contain a one-of value determined according to the discriminant, and exposes the value of the discriminant for that type, such as in an XDR union.
  • Implemented by types that can be deserialized from Bytes.
  • Name defines types that assign a static name to their value, such as the name given to an identifier in an XDR enum, or the name given to the case in a union.
  • Implemented by types that can be serialized to Bytes.
  • Iter defines types that have variants that can be iterated.

Type Definitions