diff --git a/crates/ely_browser_core/src/state.rs b/crates/ely_browser_core/src/state.rs index efcd061..6a09e1f 100644 --- a/crates/ely_browser_core/src/state.rs +++ b/crates/ely_browser_core/src/state.rs @@ -30,6 +30,7 @@ mod space_exports; mod spaces; mod splits; mod sync; +mod sync_apply; mod sync_context; mod sync_notes; mod sync_profiles; diff --git a/crates/ely_browser_core/src/state/sync.rs b/crates/ely_browser_core/src/state/sync.rs index 8f1ac74..f2e07b6 100644 --- a/crates/ely_browser_core/src/state/sync.rs +++ b/crates/ely_browser_core/src/state/sync.rs @@ -9,7 +9,7 @@ use ely_sync_client::SyncClientError; use super::{BrowserCore, sync_context::SyncSnapshotApplyContext}; use crate::sync_engine::SyncSnapshotApplySummary; -use crate::sync_records::{BookmarkSyncRecord, SpaceSyncRecord, SyncSnapshotBody, TabSyncRecord}; +use crate::sync_records::{BookmarkSyncRecord, SpaceSyncRecord, TabSyncRecord}; #[derive(Clone, Debug)] pub(super) struct SyncObjectPolicies { @@ -106,33 +106,6 @@ impl BrowserCore { .map(|space| space.name().to_string()) } - pub(crate) fn apply_sync_snapshot_body( - &mut self, - body: SyncSnapshotBody, - ) -> Result { - let mut summary = SyncSnapshotApplySummary::default(); - let mut context = SyncSnapshotApplyContext::default(); - for record in body.profiles { - self.apply_profile_sync_record(record, &mut summary, &mut context)?; - } - for record in body.spaces { - self.apply_space_sync_record(record, &mut summary, &context)?; - } - for record in body.tabs { - self.apply_tab_sync_record(record, &mut summary, &context)?; - } - for record in body.bookmarks { - self.apply_bookmark_sync_record(record, &mut summary, &context)?; - } - for record in body.notes { - self.apply_note_sync_record(record, &mut summary, &context)?; - } - for record in body.reading_list { - self.apply_reading_list_sync_record(record, &mut summary, &context)?; - } - Ok(summary) - } - pub(super) fn sync_status(&self) -> SyncStatus { let enabled_state = match &self.sync_connection_state { SyncConnectionState::SyncReady { .. } => SyncObjectState::Synced, @@ -218,7 +191,7 @@ impl BrowserCore { self.spaces.iter().collect() } - fn apply_space_sync_record( + pub(super) fn apply_space_sync_record( &mut self, record: SpaceSyncRecord, summary: &mut SyncSnapshotApplySummary, @@ -297,7 +270,7 @@ impl BrowserCore { changed } - fn apply_tab_sync_record( + pub(super) fn apply_tab_sync_record( &mut self, record: TabSyncRecord, summary: &mut SyncSnapshotApplySummary, @@ -346,7 +319,7 @@ impl BrowserCore { Ok(()) } - fn apply_bookmark_sync_record( + pub(super) fn apply_bookmark_sync_record( &mut self, record: BookmarkSyncRecord, summary: &mut SyncSnapshotApplySummary, diff --git a/crates/ely_browser_core/src/state/sync_apply.rs b/crates/ely_browser_core/src/state/sync_apply.rs new file mode 100644 index 0000000..d1112e1 --- /dev/null +++ b/crates/ely_browser_core/src/state/sync_apply.rs @@ -0,0 +1,33 @@ +use ely_sync_client::SyncClientError; + +use super::{BrowserCore, sync_context::SyncSnapshotApplyContext}; +use crate::{sync_engine::SyncSnapshotApplySummary, sync_records::SyncSnapshotBody}; + +impl BrowserCore { + pub(crate) fn apply_sync_snapshot_body( + &mut self, + body: SyncSnapshotBody, + ) -> Result { + let mut summary = SyncSnapshotApplySummary::default(); + let mut context = SyncSnapshotApplyContext::default(); + for record in body.profiles { + self.apply_profile_sync_record(record, &mut summary, &mut context)?; + } + for record in body.spaces { + self.apply_space_sync_record(record, &mut summary, &context)?; + } + for record in body.tabs { + self.apply_tab_sync_record(record, &mut summary, &context)?; + } + for record in body.bookmarks { + self.apply_bookmark_sync_record(record, &mut summary, &context)?; + } + for record in body.notes { + self.apply_note_sync_record(record, &mut summary, &context)?; + } + for record in body.reading_list { + self.apply_reading_list_sync_record(record, &mut summary, &context)?; + } + Ok(summary) + } +}