pub struct Coordinator<'a> { /* private fields */ }Expand description
A source paired with an engine.
Implementations§
Source§impl<'a> Coordinator<'a>
impl<'a> Coordinator<'a>
pub fn new( engine: &'a mut dyn EngineClient, source: &'a mut dyn SyncSource, ) -> Self
Sourcepub fn sync_in(&mut self) -> Result<SyncInSummary>
pub fn sync_in(&mut self) -> Result<SyncInSummary>
source → engine: the source’s full current scope.
Sourcepub fn reconcile(&mut self, paths: &[String]) -> Result<SyncInSummary>
pub fn reconcile(&mut self, paths: &[String]) -> Result<SyncInSummary>
source → engine for a set of paths: fetch each; present items go to
observe_many in one call, gone paths to observe_delete one by one.
Sourcepub fn sync_out(&mut self, cursor: i64) -> Result<SyncOutSummary>
pub fn sync_out(&mut self, cursor: i64) -> Result<SyncOutSummary>
engine → source: page changes_since(cursor); for every digest whose
origin is not observed, every revision’s doc is re-read by path and
written, or removed when it no longer reads; follows truncated
pages; returns the final cursor. A source without write-through
exports nothing and returns cursor unchanged.
Sourcepub fn watch_in(&mut self) -> Result<Option<Receiver<WatchEvent>>>
pub fn watch_in(&mut self) -> Result<Option<Receiver<WatchEvent>>>
Live source → engine: subscribe when the source can watch; None
otherwise. The stream yields WatchEvent::Ready once the feed is
primed (a host waits for it — crate::wait_ready — before its
priming sweep, §5), then batches. Drive it with
Coordinator::handle_batches or call Coordinator::reconcile per
received batch.
Sourcepub fn handle_batches(
&mut self,
events: &Receiver<WatchEvent>,
on_summary: impl FnMut(SyncInSummary),
on_error: impl FnMut(Error),
)
pub fn handle_batches( &mut self, events: &Receiver<WatchEvent>, on_summary: impl FnMut(SyncInSummary), on_error: impl FnMut(Error), )
Reconcile every batch the stream yields until it closes (the adapter
exited or unwatch ran), reporting each summary or error. Ready is
not a batch and is skipped.
Sourcepub fn stop_watch(&mut self) -> Result<()>
pub fn stop_watch(&mut self) -> Result<()>
Stop the watch stream.