Skip to content

no_std AimX server (dispatch) port — cross-cutting AnyRecord + RecordMetadataTracker de-std #120

@lxsaah

Description

@lxsaah

Follow-up to #39 / design doc 041. Deliberately excluded from the Phase 6 foundation PR to keep that change low-risk; tracked here on the roadmap.

Context

The Phase 6 foundation PR landed: generic SessionClientConnector/SessionServerConnector, the aimdb-uds-connector crate (UDS triple + socket-setup relocated out of core), with_remote_access(config) removed in favor of .with_connector(UdsServer::from_config(cfg)), and AimxCodec made no_std + alloc (the embedded client path — a sensor dialing a gateway).

What's not done: the AimX server dispatch (AimxDispatch/AimxSession) is still #[cfg(feature = "std")]. That unblocks the "board serves host over serial" scenario (an MCU answering record.list/drain/subscribe/write).

Why it was split out

Tracing the dependency to the bottom, making the dispatch no_std is a cross-cutting refactor of core's central record API, not a mechanical re-gate:

  • Re-gate the AnyRecord trait methods collect_metadata / latest_json / subscribe_json / set_from_json (all #[cfg(std)] today) off the std gate — a trait every record type implements.
  • De-std RecordMetadataTracker: std::sync::Mutexspin::Mutex, std atomics → core/portable-atomic, SystemTime::now() → cfg'd (zeroed timestamps on an MCU — no wall clock).
  • De-std the remote module: AimxConfig.socket_path PathBufString, SecurityPolicy HashSethashbrown, gate the thiserror/std::io::Error bits (RemoteError). Re-gate from std to json-serialize.
  • Re-gate AimDb/AimDbInner JSON API (list_records / try_latest_as_json / set_record_from_json) off std.
  • Finally re-gate AimxDispatch/AimxSession to connector-session + json-serialize; swap std::collectionshashbrown, std::sync::Arcalloc::sync::Arc.

Verification target

cargo check -p aimdb-core --no-default-features \
  --features "alloc,connector-session,json-serialize" \
  --target thumbv7em-none-eabihf

must build the AimX dispatch (not just the codec, which already cross-compiles). Add the line to the Makefile test-embedded target.

Out of scope (separate follow-ups, also from doc 041)

  • aimdb-serial-connector (COBS framing, tokio + Embassy halves)
  • aimdb-tcp-connector (tokio + embassy-net)
  • host client AimxConnection::connect_over / connect_url
  • cli/mcp --connect <url> / AIMDB_CONNECT resolver

Each builds on the foundation already merged.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions