Trait diffedit3::types::DataInterface
source · pub trait DataInterface: Send + Sync + 'static {
// Required methods
fn scan(&self) -> Result<EntriesToCompare, DataReadError>;
fn save_unchecked(
&mut self,
result: IndexMap<String, String>
) -> Result<(), DataSaveError>;
// Provided methods
fn get_valid_entries(&mut self) -> Result<HashSet<PathBuf>, DataReadError> { ... }
fn save(
&mut self,
result: IndexMap<String, String>
) -> Result<(), DataSaveError> { ... }
}Required Methods§
sourcefn scan(&self) -> Result<EntriesToCompare, DataReadError>
fn scan(&self) -> Result<EntriesToCompare, DataReadError>
Return the content of either the original files to merge or the last-saved version.
A scan() after a successful save() should return the saved results.
sourcefn save_unchecked(
&mut self,
result: IndexMap<String, String>
) -> Result<(), DataSaveError>
fn save_unchecked( &mut self, result: IndexMap<String, String> ) -> Result<(), DataSaveError>
Do not use this method directly, as it does not check whether the requested paths are safe to save to.
Provided Methods§
sourcefn get_valid_entries(&mut self) -> Result<HashSet<PathBuf>, DataReadError>
fn get_valid_entries(&mut self) -> Result<HashSet<PathBuf>, DataReadError>
Get a list of all the files we were originally asked to merge.
The default implementation may be very inefficient.
sourcefn save(
&mut self,
result: IndexMap<String, String>
) -> Result<(), DataSaveError>
fn save( &mut self, result: IndexMap<String, String> ) -> Result<(), DataSaveError>
Save the result. First, check that each file being saved was one of the files we were comparing originally.
This check helps with two potential problems when running a local server:
- The frontend webapp could be connected to a different server than it was started with.
- A malicious frontend could try making the diff editor save to
../../../../home/$USER/.bashrc.