Skip to content

Extensible Streamable Registry — Remove Closed Dispatcher, Add Builder Registration #79

@lxsaah

Description

@lxsaah

Summary

Remove the closed for_each_streamable() dispatcher from aimdb-data-contracts and add .register::<T>() builder methods to connectors/adapters. Publish aimdb-data-contracts to crates.io so users can depend on it for traits and built-in types. This unblocks crates.io publishing for aimdb-websocket-connector and aimdb-wasm-adapter.

Problem

The current for_each_streamable() in aimdb-data-contracts is a closed registry hardcoded to 3 built-in types (Temperature, Humidity, GpsLocation). This causes two issues:

  1. Users can't register custom contracts. A user-defined MyCustomSensor: Streamable is invisible to the WebSocket connector and WASM adapter — the dispatcher never discovers it.
  2. crates.io publishing blocked. aimdb-websocket-connector and aimdb-wasm-adapter depend on aimdb-data-contracts (not published) solely for the dispatcher function.

Proposed Solution

  1. Remove for_each_streamable() and StreamableVisitor from aimdb-data-contracts (breaking)
  2. Add .register::<T: Streamable>() builder method to WebSocketConnector, WsBridge, and WasmDb
  3. Publish aimdb-data-contracts to crates.io — traits and built-in types available to all users
  4. Remove aimdb-data-contracts dependency from aimdb-websocket-connector and aimdb-wasm-adapter
  5. Add version constraints to aimdb-websocket-connector's path-only deps

All traits (SchemaType, Streamable, Linkable, Simulatable) stay in aimdb-data-contracts — no code moves to aimdb-core.

User-facing API after change

use aimdb_data_contracts::contracts::{Temperature, Humidity, GpsLocation};

let ws = WebSocketConnector::new()
    .register::<Temperature>()
    .register::<Humidity>()
    .register::<GpsLocation>()
    .register::<MyCustomSensor>()      // user's own type
    .register::<MyActuatorCommand>()   // another custom type
    .bind("0.0.0.0:8080")
    .path("/ws");

Breaking Changes

  • for_each_streamable() and StreamableVisitor removed from aimdb-data-contracts
  • WebSocketConnector no longer auto-discovers types — users must .register::<T>() every type they need
  • WsBridge / WasmDb same — explicit .register::<T>() required

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

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