migrate_memory

Function migrate_memory 

Source
pub async fn migrate_memory(
    source: &dyn Memory,
    target: &dyn Memory,
    agent_id: &str,
) -> Result<usize, String>
Expand description

Migrates memory entries from one backend to another.

§Arguments

  • source - The source memory backend to read from
  • target - The target memory backend to write to
  • agent_id - Agent ID to migrate memories for

§Returns

The number of entries migrated, or an error message

§Examples

use ceylon_next::memory::{InMemoryStore, FileStore, StorageFormat, migrate_memory};
use std::sync::Arc;

#[tokio::main]
async fn main() {
    let source = Arc::new(InMemoryStore::new());
    let target = Arc::new(
        FileStore::new("backup.json", StorageFormat::Json).await.unwrap()
    );

    // Migrate specific agent's memories
    let count = migrate_memory(&*source, &*target, "agent-123").await.unwrap();
    println!("Migrated {} entries for agent-123", count);
}