Skip to content

Commit

Permalink
feat: add support for no_std env
Browse files Browse the repository at this point in the history
  • Loading branch information
overcat committed Sep 12, 2024
1 parent 5315f4c commit 4b490d6
Show file tree
Hide file tree
Showing 6 changed files with 2,073 additions and 1,953 deletions.
21 changes: 18 additions & 3 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 7 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,25 +19,28 @@ doctest = false
crate-git-revision = "0.0.6"

[dependencies]
stellar-strkey = { version = "0.0.9", optional = true }
stellar-strkey = { version = "0.0.11", optional = true }
base64 = { version = "0.13.0", optional = true }
serde = { version = "1.0.139", features = ["derive"], optional = true }
serde_with = { version = "3.0.0", optional = true }
escape-bytes = { version = "0.1.1", default-features = false }
hex = { version = "0.4.3", optional = true }
arbitrary = {version = "1.1.3", features = ["derive"], optional = true}
hex = { version = "0.4.3", default-features = false, optional = true }
arbitrary = { version = "1.1.3", features = ["derive"], optional = true }
clap = { version = "4.2.4", default-features = false, features = ["std", "derive", "usage", "help"], optional = true }
serde_json = { version = "1.0.89", optional = true }
thiserror = { version = "1.0.37", optional = true }
schemars = { version = "0.8.16", optional = true }
embedded-io = { version = "0.6.1", default-features = false, optional = true }
embedded-io-cursor = { git = "https://github.com/lightsail-network/embedded-io-cursor", rev = "0b7ff9270d7ec1d3204375650f04cb0258ac1ada", default-features = false, features = ["alloc"], optional = true }
# TODO: embedded-io-cursor not published yet.

[dev-dependencies]
serde_json = "1.0.89"

[features]
default = ["std", "curr"]
std = ["alloc"]
alloc = ["dep:hex", "dep:stellar-strkey", "escape-bytes/alloc"]
alloc = ["dep:hex", "dep:stellar-strkey", "dep:embedded-io", "dep:embedded-io-cursor", "escape-bytes/alloc", "hex/alloc"]
curr = []
next = []

Expand Down
7 changes: 4 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ CARGO_HACK_ARGS=--feature-powerset --exclude-features default --group-features b

CARGO_DOC_ARGS?=--open

XDRGEN_VERSION=b7bc57ecdd277c9575930d3e17c12dfaa76655fc
# TODO: Update this after https://github.com/stellar/xdrgen/pull/205 is merged
XDRGEN_VERSION=ecf547f1bca98545378e55c7e55aa0ef3cf4e66a
# XDRGEN_LOCAL=1
XDRGEN_TYPES_CUSTOM_STR_IMPL_CURR=PublicKey,AccountId,MuxedAccount,MuxedAccountMed25519,SignerKey,SignerKeyEd25519SignedPayload,NodeId,ScAddress,AssetCode,AssetCode4,AssetCode12,ClaimableBalanceId
XDRGEN_TYPES_CUSTOM_STR_IMPL_NEXT=PublicKey,AccountId,MuxedAccount,MuxedAccountMed25519,SignerKey,SignerKeyEd25519SignedPayload,NodeId,ScAddress,AssetCode,AssetCode4,AssetCode12,ClaimableBalanceId
Expand Down Expand Up @@ -44,7 +45,7 @@ src/curr/generated.rs: $(sort $(wildcard xdr/curr/*.x))
ifeq ($(XDRGEN_LOCAL),)
docker run -i --rm -v $$PWD:/wd -w /wd docker.io/library/ruby:latest /bin/bash -c '\
gem install specific_install -v 0.3.8 && \
gem specific_install https://github.com/stellar/xdrgen.git -b $(XDRGEN_VERSION) && \
gem specific_install https://github.com/lightsail-network/xdrgen.git -b $(XDRGEN_VERSION) && \
xdrgen --language rust --namespace generated --output src/curr \
--rust-types-custom-str-impl $(XDRGEN_TYPES_CUSTOM_STR_IMPL_CURR) \
--rust-types-custom-jsonschema-impl '$(XDRGEN_TYPES_CUSTOM_JSONSCHEMA_IMPL_CURR)' \
Expand All @@ -69,7 +70,7 @@ src/next/generated.rs: $(sort $(wildcard xdr/next/*.x))
ifeq ($(XDRGEN_LOCAL),)
docker run -i --rm -v $$PWD:/wd -w /wd docker.io/library/ruby:latest /bin/bash -c '\
gem install specific_install -v 0.3.8 && \
gem specific_install https://github.com/stellar/xdrgen.git -b $(XDRGEN_VERSION) && \
gem specific_install https://github.com/lightsail-network/xdrgen.git -b $(XDRGEN_VERSION) && \
xdrgen --language rust --namespace generated --output src/next \
--rust-types-custom-str-impl $(XDRGEN_TYPES_CUSTOM_STR_IMPL_NEXT) \
--rust-types-custom-jsonschema-impl '$(XDRGEN_TYPES_CUSTOM_JSONSCHEMA_IMPL_NEXT)' \
Expand Down
5 changes: 2 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,13 @@ decode), and is the default feature set.
2. `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].
allocator will be added in [#39]. Encode or decode capability exists,
but still in an experimental stage, there may be breaking changes at any time.
3. If std or alloc are not enabled recursive and array types requires static
lifetime values. No encode or decode capability exists. Encode and decode
capability will be added in [#47].

[#39]: https://github.com/stellar/rs-stellar-xdr/issues/39
[#46]: https://github.com/stellar/rs-stellar-xdr/issues/46
[#47]: https://github.com/stellar/rs-stellar-xdr/issues/47

Ancillary functionality:
Expand Down
Loading

0 comments on commit 4b490d6

Please sign in to comment.