pub trait AimDbSyncExt {
// Required method
fn attach(self) -> DbResult<AimDbHandle>;
}Expand description
Extension trait to add attach() method to AimDb.
This trait provides an alternative entry point to the sync API by allowing
an already-built AimDb instance to be attached to a background runtime thread.
Required Methods§
Sourcefn attach(self) -> DbResult<AimDbHandle>
fn attach(self) -> DbResult<AimDbHandle>
Attach the database to a background runtime thread.
Takes ownership of the database and spawns a dedicated thread running a Tokio runtime. Returns a handle for sync API access.
§Errors
DbError::AttachFailedif the runtime thread fails to start
§Example
ⓘ
use aimdb_core::AimDbBuilder;
use aimdb_tokio_adapter::TokioAdapter;
use aimdb_sync::AimDbSyncExt;
use std::sync::Arc;
let db = AimDbBuilder::new()
.runtime(Arc::new(TokioAdapter::new()?))
.build()?;
let handle = db.attach()?;