driven/sync/
propagator.rs1use super::SyncEngine;
4use crate::Result;
5use std::path::Path;
6
7#[derive(Debug)]
9pub struct ChangePropagator<'a> {
10 sync_engine: &'a SyncEngine,
11}
12
13impl<'a> ChangePropagator<'a> {
14 pub fn new(sync_engine: &'a SyncEngine) -> Self {
16 Self { sync_engine }
17 }
18
19 pub fn propagate(&self, project_root: &Path) -> Result<PropagationResult> {
21 let report = self.sync_engine.sync(project_root)?;
22
23 Ok(PropagationResult {
24 files_updated: report.synced_count(),
25 errors: report.errors.len(),
26 })
27 }
28}
29
30#[derive(Debug)]
32pub struct PropagationResult {
33 pub files_updated: usize,
35 pub errors: usize,
37}
38
39impl PropagationResult {
40 pub fn is_success(&self) -> bool {
42 self.errors == 0
43 }
44}
45
46#[cfg(test)]
47mod tests {
48 use super::*;
49
50 #[test]
51 fn test_propagation_result() {
52 let result = PropagationResult {
53 files_updated: 3,
54 errors: 0,
55 };
56 assert!(result.is_success());
57
58 let failed = PropagationResult {
59 files_updated: 1,
60 errors: 2,
61 };
62 assert!(!failed.is_success());
63 }
64}