Module sync_engine

Module sync_engine 

Source
Expand description

Sync engine integration traits.

Defines the interface for integrating with a sync/storage backend. Uses sync_engine::SyncItem directly for tight integration with the sync-engine crate.

§Example

use replication_engine::sync_engine::{SyncEngineRef, SyncResult, SyncError, BoxFuture};
use sync_engine::SyncItem;
use std::pin::Pin;
use std::future::Future;

struct MyBackend { /* ... */ }

impl SyncEngineRef for MyBackend {
    fn should_accept_writes(&self) -> bool {
        true // Always accept in example
    }

    fn is_current(&self, _key: &str, _hash: &str) -> Pin<Box<dyn Future<Output = SyncResult<bool>> + Send + '_>> {
        Box::pin(async move { Ok(true) })
    }

    fn submit(&self, item: SyncItem) -> Pin<Box<dyn Future<Output = SyncResult<()>> + Send + '_>> {
        Box::pin(async move { Ok(()) })
    }

    fn delete(&self, _key: String) -> Pin<Box<dyn Future<Output = SyncResult<bool>> + Send + '_>> {
        Box::pin(async move { Ok(true) })
    }

    fn delete_replicated(&self, _key: String) -> Pin<Box<dyn Future<Output = SyncResult<bool>> + Send + '_>> {
        Box::pin(async move { Ok(true) })
    }

    fn get_merkle_root(&self) -> BoxFuture<'_, Option<[u8; 32]>> {
        Box::pin(async move { Ok(None) })
    }

    fn get_merkle_children(&self, _path: &str) -> BoxFuture<'_, Vec<(String, [u8; 32])>> {
        Box::pin(async move { Ok(vec![]) })
    }

    fn get(&self, _key: &str) -> BoxFuture<'_, Option<Vec<u8>>> {
        Box::pin(async move { Ok(None) })
    }
}

Structs§

NoOpSyncEngine
A no-op implementation for testing/standalone mode.
SyncError
Simplified error for sync engine operations.
SyncItem
A wrapper struct that separates metadata from content.

Enums§

BackpressureLevel
Backpressure level based on memory/queue pressure.

Traits§

SyncEngineRef
Trait defining what we need from sync-engine.

Type Aliases§

BoxFuture
Type alias for boxed async futures (reduces trait signature complexity).
SyncResult
Result type for sync engine operations.