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§

source

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.

source

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§

source

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.

source

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.

Implementors§