Skip to content

Commit dc95346

Browse files
committed
Add std feature and make it the default
This enables `serde_json` dependency, which is needed for deserializing response messages. This will mean that client-side API will not be available for `no_std` environments. This isn't as big an issue as it would seem since typically on micrcontrolers, one would implement services, not clients. Morever, this limitation will hopefully be lifted once [`serde-json-core` supports complex enums][ce]. On the bright side, we can now make `serde-json-core` and `heapless` optional dependencies, which will help `std` users avoid these dependencies that they are unlikely to otherwise depend on. This also adds a `embedded` feature, which will enable `heapless` and `serde-json-core` dependencies. Users must enable either `std` or `embedded` feature to use this crate. [ce]: rust-embedded-community/serde-json-core#94
1 parent 8e7ba9d commit dc95346

File tree

3 files changed

+150
-5
lines changed

3 files changed

+150
-5
lines changed

Cargo.lock

Lines changed: 135 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

zarlink/Cargo.toml

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,17 @@ version = "0.1.0"
44
edition = "2021"
55

66
[features]
7-
default = ["alloc"]
8-
alloc = []
7+
default = ["std"]
8+
std = ["dep:serde_json", "memchr/std"]
9+
embedded = ["dep:serde-json-core", "dep:heapless"]
910

1011
[dependencies]
12+
serde = { version = "1.0.218", default-features = false, features = ["derive"] }
13+
serde_json = { version = "1.0.139", features = [
14+
"arbitrary_precision",
15+
], optional = true }
16+
serde-json-core = { version = "0.6.0", default-features = false, features = [
17+
"heapless",
18+
], optional = true }
19+
heapless = { version = "0.8.0", optional = true }
20+
memchr = { version = "2.7.4", default-features = false }

zarlink/src/lib.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#![no_std]
1+
#![cfg_attr(not(feature = "std"), no_std)]
22
#![deny(
33
missing_debug_implementations,
44
nonstandard_style,
@@ -8,8 +8,8 @@
88
#![warn(unreachable_pub)]
99
#![doc = include_str!("../../README.md")]
1010

11-
#[cfg(not(feature = "alloc"))]
12-
compile_error!("Currently the `alloc` feature is required");
11+
#[cfg(all(not(feature = "std"), not(feature = "embedded")))]
12+
compile_error!("Either 'std' or 'embedded' feature must be enabled.");
1313

1414
pub mod connection;
1515
mod error;

0 commit comments

Comments
 (0)