AimDbSyncExt

Trait AimDbSyncExt 

Source
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§

Source

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::AttachFailed if 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()?;

Implementations on Foreign Types§

Source§

impl AimDbSyncExt for AimDb<TokioAdapter>

Implementors§