Skip to content

aimdb-sync: std feature gate + no_std flip + CI lane #199

Description

@lxsaah

Background

With the std-crates cleared (#197), aimdb-sync can be made no_std-ready. This is the step that needs actual care: the crate has default = [] today and tokio + aimdb-tokio-adapter as unconditional dependencies, so introducing a default-on std feature touches every downstream consumer.

The feature gate, the no_std flip, and the CI lane belong together — a no_std build that is not in CI rots before anyone notices it, and the feature gate on its own accomplishes nothing observable.

Task

1. Introduce the std feature

  • Add a default-on std feature to aimdb-sync/Cargo.toml (default = ["std"] — note it is default = [] today, line 36).
  • Move tokio and aimdb-tokio-adapter behind it (optional = true + listed in the std feature), with no leakage into the default no_std build.
  • #[cfg(feature = "std")] the modules and items that need the runtime thread / tokio handle.
  • Run a feature-unification pass over examples/sync-api-demo and any other consumer — flipping the default set can silently enable features elsewhere.

2. Flip to no_std

  • #![cfg_attr(not(feature = "std"), no_std)] + extern crate alloc in aimdb-sync/src/lib.rs.
  • Swap std:: imports for core:: / alloc:: equivalents wherever they are not behind the std feature — String in SyncError, Arc, Duration, etc.
  • Reference: aimdb-core/src/lib.rs:16 is already no_std + alloc.

3. Guard it in CI

  • Add a no_std build lane for aimdb-sync to the build: target in the Makefile, mirroring the aimdb-core lines at Makefile:75-82.
  • Add a tokio-leak assertion so a stray dependency cannot creep back in:
    cargo tree -p aimdb-sync --no-default-features -e features | grep -i tokio   # expect: no output

Why it matters

This is the actual deliverable of #46 Phase 1: aimdb-sync compiles without std, while current users see no change. It is the precondition for any future FreeRTOS or Embassy backend.

Verification

cargo build -p aimdb-sync                       # std path unchanged
cargo build -p aimdb-sync --no-default-features # no_std path compiles
cargo tree -p aimdb-sync --no-default-features -e features | grep -i tokio  # no output
cargo test -p aimdb-sync
make check

examples/sync-api-demo must build and behave identically — "no #[tokio::main] needed" stays true for current users.

Files

  • aimdb-sync/Cargo.toml, aimdb-sync/src/lib.rs (+ #[cfg] across the crate)
  • Makefile (build: target)
  • Reference: aimdb-core/src/lib.rs:16, Makefile:75-82

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions