pub struct SyncManager { /* private fields */ }Available on crate feature
sync only.Expand description
Orchestrator for sync operations between two PulseDB instances.
The SyncManager is a sidecar — it holds Arc<PulseDB> but doesn’t
wrap it. Local database operations are completely unaffected by sync state.
§Example
use std::sync::Arc;
use pulsedb::{PulseDB, Config};
use pulsedb::sync::{SyncManager, SyncConfig, InMemorySyncTransport};
let db = Arc::new(PulseDB::open("my.db", Config::default())?);
let (local_transport, _remote) = InMemorySyncTransport::new_pair();
let mut manager = SyncManager::new(db, Box::new(local_transport), SyncConfig::default());
manager.start().await?;
// ... sync runs in background ...
manager.stop().await?;Implementations§
Source§impl SyncManager
impl SyncManager
Sourcepub fn new(
db: Arc<PulseDB>,
transport: Box<dyn SyncTransport>,
config: SyncConfig,
) -> Self
pub fn new( db: Arc<PulseDB>, transport: Box<dyn SyncTransport>, config: SyncConfig, ) -> Self
Creates a new SyncManager.
Does NOT start sync — call start() or
sync_once() to begin.
Sourcepub async fn start(&mut self) -> Result<(), SyncError>
pub async fn start(&mut self) -> Result<(), SyncError>
Starts the background sync loop.
Performs a handshake with the remote peer, then spawns a background tokio task that pushes and pulls on the configured intervals.
Sourcepub async fn sync_once(&mut self) -> Result<SyncStatus, SyncError>
pub async fn sync_once(&mut self) -> Result<SyncStatus, SyncError>
Performs a single push+pull sync cycle (no background task needed).
Useful for testing or manual sync triggers.
Sourcepub async fn initial_sync(
&mut self,
progress: Option<Box<dyn SyncProgressCallback>>,
) -> Result<(), SyncError>
pub async fn initial_sync( &mut self, progress: Option<Box<dyn SyncProgressCallback>>, ) -> Result<(), SyncError>
Performs initial sync — pulls all remote changes in batches.
Call this before start() to catch up from a cold start.
Sourcepub fn status(&self) -> SyncStatus
pub fn status(&self) -> SyncStatus
Returns the current sync status.
Auto Trait Implementations§
impl Freeze for SyncManager
impl !RefUnwindSafe for SyncManager
impl Send for SyncManager
impl Sync for SyncManager
impl Unpin for SyncManager
impl UnsafeUnpin for SyncManager
impl !UnwindSafe for SyncManager
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more