pub fn sync(&self) -> Result<(), WrashError> {
        if self.path.is_none() {
            return Err(WrashError::FailedIo(std::io::Error::new(
                std::io::ErrorKind::Other,
                "no history file exists for struct instance",
            )));
        }

        let s = serde_yaml::to_string(self.history.as_slice())
            .expect("to-string should not have erred");

        let mut history_file = match File::create(self.path.as_ref().unwrap().as_path()) {
            Ok(f) => f,
            Err(err) => match err.kind() {
                ErrorKind::NotFound => {
                    if let Some(parent) = self.path.as_ref().unwrap().parent() {
                        fs::create_dir_all(parent)?;
                    }

                    File::create(self.path.as_ref().unwrap().as_path())?
                }
                _ => return Err(WrashError::FailedIo(err)),
            },
        };

        write!(history_file, "{}", s)?;

        Ok(())
    }
/// Sync the current in-memory history with the history file.
///
/// If the history is stored in memory only (self.path == None), this
/// method returns an error.
Sync the current in-memory history with the history file.
If the history is stored in memory only (self.path == None), this
method returns an error.
Sync the current in - memory history with the history file . If the history is stored in memory only ( self . path == None ) this method returns an error .
pub fn sync(&self) -> Result<(), WrashError> {
        if self.path.is_none() {
            return Err(WrashError::FailedIo(std::io::Error::new(
                std::io::ErrorKind::Other,
                "no history file exists for struct instance",
            )));
        }
        let s = serde_yaml::to_string(self.history.as_slice())
            .expect("to-string should not have erred");
        let mut history_file = match File::create(self.path.as_ref().unwrap().as_path()) {
            Ok(f) => f,
            Err(err) => match err.kind() {
                ErrorKind::NotFound => {
                    if let Some(parent) = self.path.as_ref().unwrap().parent() {
                        fs::create_dir_all(parent)?;
                    }
                    File::create(self.path.as_ref().unwrap().as_path())?
                }
                _ => return Err(WrashError::FailedIo(err)),
            },
        };
        write!(history_file, "{}", s)?;
        Ok(())
    }
pub fn sync ( & self ) -> Result < ( ) , WrashError > { if self . path . is_none ( ) { return Err ( WrashError :: FailedIo ( std :: io :: Error :: new ( std :: io :: ErrorKind :: Other , " " , ) ) ) ; } let s = serde_yaml :: to_string ( self . history . as_slice ( ) ) . expect ( " " ) ; let mut history_file = match File :: create ( self . path . as_ref ( ) . unwrap ( ) . as_path ( ) ) { Ok ( f ) => f , Err ( err ) => match err . kind ( ) { ErrorKind :: NotFound => { if let Some ( parent ) = self . path . as_ref ( ) . unwrap ( ) . parent ( ) { fs :: create_dir_all ( parent ) ? ; } File :: create ( self . path . as_ref ( ) . unwrap ( ) . as_path ( ) ) ? } _ => return Err ( WrashError :: FailedIo ( err ) ) , } , } ; write ! ( history_file " " s ) ? ; Ok ( ( ) ) }
Sync the current in-memory history with the history file.
Sync the current in - memory history with the history file .
&self