pub trait AimDbBuilderSyncExt {
// Required method
fn attach(self) -> DbResult<AimDbHandle>;
}Expand description
Extension trait to add attach() method to AimDbBuilder.
This trait provides the entry point to the sync API by allowing
an AimDbBuilder instance to build the database and attach it to
a background runtime thread in one step.
Required Methods§
Sourcefn attach(self) -> DbResult<AimDbHandle>
fn attach(self) -> DbResult<AimDbHandle>
Build the database inside a runtime thread and attach for sync API.
This method takes a configured builder (WITH .runtime(TokioAdapter) set),
spawns a background thread with a Tokio runtime, builds the database
inside that context, and returns a sync handle.
Important: Call .runtime(Arc::new(TokioAdapter)) before .attach().
Even though TokioAdapter is created in sync context, the actual building
happens in the async context where it can be used.
§Errors
DbError::RuntimeErrorif the database fails to buildDbError::AttachFailedif the runtime thread fails to start
§Example
ⓘ
use aimdb_core::AimDbBuilder;
use aimdb_tokio_adapter::TokioAdapter;
use aimdb_sync::AimDbBuilderSyncExt;
use std::sync::Arc;
let mut builder = AimDbBuilder::new()
.runtime(Arc::new(TokioAdapter)); // Create adapter (it's just a marker)
builder.configure::<MyData>(|reg| {
// Configure buffer, sources, taps, etc.
});
let handle = builder.attach()?; // Build happens in runtime thread