Skip to main content

aimdb_core/
lib.rs

1//! AimDB Core Database Engine
2//!
3//! # aimdb-core
4//!
5//! Type-safe, async in-memory database for data synchronization
6//! across MCU → edge → cloud environments.
7//!
8//! # Architecture
9//!
10//! - **RecordKey/RecordId**: Stable identifiers for multi-instance records
11//! - **Unified API**: Single `Database<A>` type for all operations
12//! - **Runtime Agnostic**: Works with Tokio (std) or Embassy (embedded)
13//! - **Producer-Consumer**: Built-in typed message passing
14//!
15//! See examples in the repository for usage patterns.
16
17#![cfg_attr(not(feature = "std"), no_std)]
18
19#[cfg(feature = "alloc")]
20extern crate alloc;
21
22pub mod buffer;
23pub mod builder;
24pub mod connector;
25pub mod context;
26pub mod database;
27mod error;
28pub mod ext_macros;
29pub mod extensions;
30pub mod graph;
31#[cfg(feature = "profiling")]
32pub mod profiling;
33pub mod record_id;
34#[cfg(feature = "std")]
35pub mod remote;
36pub mod router;
37pub mod time;
38pub mod transform;
39pub mod transport;
40pub mod typed_api;
41pub mod typed_record;
42
43/// Marker trait used to add a `TimeOps` requirement to runtime-agnostic builder
44/// methods *only* when the `profiling` feature is enabled.
45///
46/// When `profiling` is off this is a blanket no-op (every `R` implements it), so
47/// the public API is unchanged. When `profiling` is on it requires
48/// [`aimdb_executor::TimeOps`], which every real runtime adapter already provides
49/// (it is part of [`aimdb_executor::Runtime`]).
50#[cfg(feature = "profiling")]
51pub trait RuntimeForProfiling: aimdb_executor::TimeOps {}
52#[cfg(feature = "profiling")]
53impl<R: aimdb_executor::TimeOps> RuntimeForProfiling for R {}
54
55/// See the `profiling`-enabled definition above. Blanket no-op when `profiling`
56/// is disabled.
57#[cfg(not(feature = "profiling"))]
58pub trait RuntimeForProfiling {}
59#[cfg(not(feature = "profiling"))]
60impl<R> RuntimeForProfiling for R {}
61
62// Public API exports
63pub use context::RuntimeContext;
64pub use error::{DbError, DbResult};
65pub use extensions::Extensions;
66
67// Runtime trait re-exports from aimdb-executor
68// These traits define the platform-specific execution, timing, and logging capabilities
69pub use aimdb_executor::{
70    ExecutorError, ExecutorResult, Logger, Runtime, RuntimeAdapter, RuntimeInfo, Spawn, TimeOps,
71};
72
73// Database implementation exports
74pub use database::Database;
75
76// Producer-Consumer Pattern exports
77#[cfg(feature = "alloc")]
78pub use builder::OutboundRoute;
79pub use builder::{AimDb, AimDbBuilder};
80pub use connector::ConnectorBuilder;
81pub use transport::{Connector, ConnectorConfig, PublishError};
82pub use typed_api::{Consumer, Producer, RecordRegistrar, RecordT, StageKind};
83pub use typed_record::{AnyRecord, AnyRecordExt, TypedRecord};
84
85// Stage profiling exports (feature-gated)
86#[cfg(feature = "profiling")]
87pub use profiling::{RecordProfilingMetrics, StageMetrics, StageProfilingInfo};
88
89// Connector Infrastructure exports
90pub use connector::TopicResolverFn;
91pub use connector::{ConnectorClient, ConnectorLink, ConnectorUrl, SerializeError};
92pub use connector::{TopicProvider, TopicProviderAny, TopicProviderFn, TopicProviderWrapper};
93
94// Router exports for connector implementations
95pub use router::{Route, Router, RouterBuilder};
96
97// Record identification exports
98pub use record_id::{RecordId, RecordKey, StringKey};
99
100// Graph exports (dependency graph for record topology)
101pub use graph::{DependencyGraph, EdgeType, GraphEdge, GraphNode, RecordGraphInfo, RecordOrigin};
102
103// Transform API exports
104#[cfg(feature = "alloc")]
105pub use transform::{JoinBuilder, JoinEventRx, JoinPipeline, JoinTrigger};
106pub use transform::{TransformBuilder, TransformPipeline};