Crates.io | stellar-xdr |
lib.rs | stellar-xdr |
version | 22.0.0 |
source | src |
created_at | 2022-07-29 20:52:08.533938 |
updated_at | 2024-11-05 22:01:27.247129 |
description | Stellar XDR types, encoding, and decoding. |
homepage | https://github.com/stellar/rs-stellar-xdr |
repository | https://github.com/stellar/rs-stellar-xdr |
max_upload_size | |
id | 635182 |
size | 4,803,215 |
Library and CLI containing types and functionality for working with Stellar XDR.
Types are generated from XDR definitions hosted at stellar/stellar-xdr using xdrgen.
To use the library, include in your toml:
stellar-xdr = { version = "...", default-features = true, features = [] }
The crate has several features, tiers of functionality, ancillary functionality, and channels of XDR.
Default features: std
, curr
.
Teirs of functionality:
std
– The std feature provides all functionality (types, encode,
decode), and is the default feature set.alloc
– The alloc feature uses Box
and Vec
types for recursive
references and arrays, and is automatically enabled if the std feature is
enabled. The default global allocator is used. Support for a custom
allocator will be added in #39. No encode or decode capability exists,
only types. Encode and decode capability will be added in #46.Ancillary functionality:
base64
– Enables support for base64 encoding and decoding.serde
– Enables support for serializing and deserializing types with
the serde crate.serde_json
– Enables support for built-in functionality specifically
for serde_json. Often not required to use the types with serde_json, and
only necessary to use utility functions that depend on serde_json.arbitrary
– Enables support for interop with the arbitrary crate.hex
– Enables support for hex in string representations of some types.
Automatically enabled when serde is enabled.schemars
– Enables support for JSON Schema generation. (Experimental)Features marked experimental may disappear at anytime, see breaking changes at anytime, or and may be minimal implementations instead of complete.
Channels of XDR:
curr
– XDR types built from the stellar/stellar-xdr
curr
branch.next
– XDR types built from the stellar/stellar-xdr
next
branch.If a single channel is enabled the types are available at the root of the crate. If multiple channels are enabled they are available in modules at the root of the crate.
To use the CLI:
cargo install --locked stellar-xdr --version ... --features cli
Parse a TransactionEnvelope
:
stellar-xdr decode --type TransactionEnvelope << -
AAAAA...
-
Parse a ScSpecEntry
stream from a contract:
stellar-xdr +next decode --type ScSpecEntry --input stream-base64 --output json-formatted << -
AAAAA...
-
Parse a BucketEntry
framed stream from a bucket file:
stellar-xdr decode --type BucketEntry --input stream-framed --output json-formatted bucket.xdr