hydrate_model/data_source/
mod.rs

1mod file_system_id_based;
2
3pub use file_system_id_based::*;
4use std::path::PathBuf;
5
6use crate::edit_context::EditContext;
7use crate::AssetId;
8
9mod file_system_path_based;
10pub use file_system_path_based::*;
11use hydrate_pipeline::{HydrateProjectConfiguration, ImportJobToQueue};
12
13#[derive(Default)]
14pub struct PendingFileOperations {
15    pub create_operations: Vec<(AssetId, PathBuf)>,
16    pub modify_operations: Vec<(AssetId, PathBuf)>,
17    pub delete_operations: Vec<(AssetId, PathBuf)>,
18}
19
20pub trait DataSource {
21    // Replace memory with storage state
22    // Reset memory to storage
23    // Load storage state to memory
24    fn load_from_storage(
25        &mut self,
26        project_config: &HydrateProjectConfiguration,
27        edit_context: &mut EditContext,
28        import_job_to_queue: &mut ImportJobToQueue,
29    );
30
31    // Replace storage state with memory state
32    // Flush memory to storage
33    fn flush_to_storage(
34        &mut self,
35        edit_context: &mut EditContext,
36    );
37
38    fn is_generated_asset(
39        &self,
40        asset_id: AssetId,
41    ) -> bool;
42
43    fn persist_generated_asset(
44        &mut self,
45        edit_context: &mut EditContext,
46        asset_id: AssetId,
47    );
48
49    fn edit_context_has_unsaved_changes(
50        &self,
51        edit_context: &EditContext,
52    ) -> bool;
53
54    fn append_pending_file_operations(
55        &self,
56        edit_context: &EditContext,
57        pending_file_operations: &mut PendingFileOperations,
58    );
59}