async fn save_classinfo(
    class: ClassInfoClass,
    classinfo: String,
) -> Result<(), FileError> {
    let temp_filepath = get_classinfo_file_path(&class, true);
    let mut temp_file = File::create(&temp_filepath).await?;

    match temp_file.write_all(classinfo.as_bytes()).await {
        Ok(_) => {
            let filepath = get_classinfo_file_path(&class, false);
            
            temp_file.flush().await?;
            async_fs::rename(temp_filepath, filepath).await?;

            Ok(())
        },
        Err(error) => {
            // something went wrong writing to this file...
            async_fs::remove_file(&temp_filepath).await?;
            
            Err(error.into())
        }
    }
}
/// Performs a basic atomic file write.
Performs a basic atomic file write.
Performs a basic atomic file write .
async fn save_classinfo(
    class: ClassInfoClass,
    classinfo: String,
) -> Result<(), FileError> {
    let temp_filepath = get_classinfo_file_path(&class, true);
    let mut temp_file = File::create(&temp_filepath).await?;
    match temp_file.write_all(classinfo.as_bytes()).await {
        Ok(_) => {
            let filepath = get_classinfo_file_path(&class, false);
            temp_file.flush().await?;
            async_fs::rename(temp_filepath, filepath).await?;
            Ok(())
        },
        Err(error) => {
            // something went wrong writing to this file...
            async_fs::remove_file(&temp_filepath).await?;
            Err(error.into())
        }
    }
}
async fn save_classinfo ( class : ClassInfoClass , classinfo : String , ) -> Result < ( ) , FileError > { let temp_filepath = get_classinfo_file_path ( & class , true ) ; let mut temp_file = File :: create ( & temp_filepath ) . await ? ; match temp_file . write_all ( classinfo . as_bytes ( ) ) . await { Ok ( _ ) => { let filepath = get_classinfo_file_path ( & class , false ) ; temp_file . flush ( ) . await ? ; async_fs :: rename ( temp_filepath , filepath ) . await ? ; Ok ( ( ) ) } , Err ( error ) => { // something went wrong writing to this file... async_fs :: remove_file ( & temp_filepath ) . await ? ; Err ( error . into ( ) ) } } }
Performs a basic atomic file write.
Performs a basic atomic file write .
class
ClassInfoClass
classinfo
String
class
ClassInfoClass
classinfo
String