Skip to content

aimdb-sync: remove std deps (thiserror 2.x, log facade, doctests) #197

Description

@lxsaah

Background

aimdb-sync is std-only today. Before it can become #![no_std] (tracked in #46) a handful of std-crates have to go. They are independent of each other and small enough to land as one PR.

Task

1. Bump thiserror to 2.x

  • aimdb-sync/Cargo.toml:21: thiserror = "1.0"thiserror = { version = "2.0.16", default-features = false }, mirroring aimdb-core/Cargo.toml:96.
  • Fix any fallout in aimdb-sync/src/error.rs (2.x is largely source-compatible — #[error(transparent)] and #[from] both still work).

The Phase 1 checklist comment on #46 says thiserror "appears unused" — that is not correct. It is used at aimdb-sync/src/error.rs:10, which derives it on SyncError. So this is a bump, not a removal.

Leave the String fields in SyncError alone; switching them to alloc::string::String belongs to the no_std flip (Phase 1b).

2. Replace eprintln! with the log facade

  • Replace the 11 eprintln! calls in aimdb-sync/src/handle.rs with the workspace log macros (log_warn! / log_error!), picking the level that matches each message.
  • Call sites: handle.rs lines 159, 169, 178, 185, 245, 485, 498, 509, 644, 645, 649.
  • The macros are #[macro_export]ed from aimdb-core/src/log.rs:35 / :44; add the import if needed.
  • Keep the message text as-is — this is a routing change, not a rewording.

The #46 comment counts 13 sites. Only these 11 are real code; the two in lib.rs:231-232 sit inside a //! doc example and are covered by item 3.

3. Drop std::error::Error from the doctests

  • Rewrite the ~16 Result<(), Box<dyn std::error::Error>> doctest signatures to use the crate's own SyncResult / SyncError, or gate the examples behind the (future) std feature.
  • Sites: producer.rs:27,127,163,200,244; consumer.rs:27,90,129,169,216,268; handle.rs:53,93,305,340,379,441,544,571; lib.rs:57,119,138 (plus the two eprintln!s in the lib.rs:231-232 example).
  • Examples that pull in aimdb_tokio_adapter::TokioAdapter are std-only by construction — those are the ones to gate rather than rewrite.

Why it matters

std::error::Error, eprintln!, and thiserror 1.0 are the three hard no_std blockers that need no design decisions — clearing them shrinks Phase 1b to the parts that actually need thought.

Verification

cargo build -p aimdb-sync
cargo test -p aimdb-sync
cargo test --doc -p aimdb-sync
make check

examples/sync-api-demo must behave identically; check that the drop-without-detach warning (handle.rs:644) still surfaces.

Files

  • aimdb-sync/Cargo.toml, aimdb-sync/src/{error,handle,producer,consumer,lib}.rs
  • Reference: aimdb-core/Cargo.toml:96, aimdb-core/src/error.rs, aimdb-core/src/log.rs

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