pub fn parse_version_against_current(
        cfg_version_str: &str,
        bonnie_version_str: &str,
        output: &mut impl std::io::Write,
    ) -> Result<(), String> {
        // Split the program and config file versions into their components
        let bonnie_version = get_version_parts(bonnie_version_str)?;
        let cfg_version = get_version_parts(cfg_version_str)?;
        // Compare the two and warn/error appropriately
        let compat = bonnie_version.is_compatible_with(&cfg_version);
        match compat {
            VersionCompatibility::DifferentBetaVersion(version_difference) => return Err("The provided configuration file is incompatible with this version of Bonnie. You are running Bonnie v".to_string() + bonnie_version_str + ", but the configuration file expects Bonnie v" + cfg_version_str + ". " + match version_difference {
                VersionDifference::TooNew => "This issue can be fixed by updating Bonnie to the appropriate version, which can be done at https://github.com/arctic-hen7/bonnie/releases.",
                VersionDifference::TooOld => "This issue can be fixed by updating the configuration file, which may require changing some of its syntax (see https://github.com/arctic-hen7/bonnie for how to do so). Alternatively, you can download an older version of Bonnie from https://github.com/arctic-hen7/bonnie/releases (not recommended)."
            }),
            VersionCompatibility::DifferentMajor(version_difference) => return Err("The provided configuration file is incompatible with this version of Bonnie. You are running Bonnie v".to_string() + bonnie_version_str + ", but the configuration file expects Bonnie v" + cfg_version_str + ". " + match version_difference {
                VersionDifference::TooNew => "This issue can be fixed by updating Bonnie to the appropriate version, which can be done at https://github.com/arctic-hen7/bonnie/releases.",
                VersionDifference::TooOld => "This issue can be fixed by updating the configuration file, which may require changing some of its syntax (see https://github.com/arctic-hen7/bonnie for how to do so). Alternatively, you can download an older version of Bonnie from https://github.com/arctic-hen7/bonnie/releases (not recommended)."
            }),
            // These next two are just warnings, not errors
            VersionCompatibility::DifferentMinor(version_difference) => writeln!(output, "{}", "The provided configuration file is compatible with this version of Bonnie, but has a different minor version. You are running Bonnie v".to_string() + bonnie_version_str + ", but the configuration file expects Bonnie v" + cfg_version_str + ". " + match version_difference {
                VersionDifference::TooNew => "This issue can be fixed by updating Bonnie to the appropriate version, which can be done at https://github.com/arctic-hen7/bonnie/releases.",
                VersionDifference::TooOld => "This issue can be fixed by updating the configuration file, which may require changing some of its syntax (see https://github.com/arctic-hen7/bonnie for how to do so). Alternatively, you can download an older version of Bonnie from https://github.com/arctic-hen7/bonnie/releases (not recommended)."
            }).expect("Failed to write warning."),
            VersionCompatibility::DifferentPatch(version_difference) => writeln!(output, "{}", "The provided configuration file is compatible with this version of Bonnie, but has a different patch version. You are running Bonnie v".to_string() + bonnie_version_str + ", but the configuration file expects Bonnie v" + cfg_version_str + ". " + match version_difference {
                VersionDifference::TooNew => "You may want to update Bonnie to the appropriate version, which can be done at https://github.com/arctic-hen7/bonnie/releases.",
                VersionDifference::TooOld => "You may want to update the configuration file (which shouldn't require any syntax changes)."
            }).expect("Failed to write warning."),
            _ => ()
        };

        // If we haven't returned an error yet, the version is valid (and warnings have been emitted as necessary)
        Ok(())
    }
// Parses the version of the config to check for compatibility issues, consuming `self`
// We extract the version of Bonnie itself for testing purposes
// This si generic because it's used in caching logic as well
Parses the version of the config to check for compatibility issues, consuming `self`
We extract the version of Bonnie itself for testing purposes
This si generic because it's used in caching logic as well
Parses the version of the config to check for compatibility issues consuming ` self ` We extract the version of Bonnie itself for testing purposes This si generic because it ' s used in caching logic as well
pub fn parse_version_against_current(
        cfg_version_str: &str,
        bonnie_version_str: &str,
        output: &mut impl std::io::Write,
    ) -> Result<(), String> {
        // Split the program and config file versions into their components
        let bonnie_version = get_version_parts(bonnie_version_str)?;
        let cfg_version = get_version_parts(cfg_version_str)?;
        // Compare the two and warn/error appropriately
        let compat = bonnie_version.is_compatible_with(&cfg_version);
        match compat {
            VersionCompatibility::DifferentBetaVersion(version_difference) => return Err("The provided configuration file is incompatible with this version of Bonnie. You are running Bonnie v".to_string() + bonnie_version_str + ", but the configuration file expects Bonnie v" + cfg_version_str + ". " + match version_difference {
                VersionDifference::TooNew => "This issue can be fixed by updating Bonnie to the appropriate version, which can be done at https://github.com/arctic-hen7/bonnie/releases.",
                VersionDifference::TooOld => "This issue can be fixed by updating the configuration file, which may require changing some of its syntax (see https://github.com/arctic-hen7/bonnie for how to do so). Alternatively, you can download an older version of Bonnie from https://github.com/arctic-hen7/bonnie/releases (not recommended)."
            }),
            VersionCompatibility::DifferentMajor(version_difference) => return Err("The provided configuration file is incompatible with this version of Bonnie. You are running Bonnie v".to_string() + bonnie_version_str + ", but the configuration file expects Bonnie v" + cfg_version_str + ". " + match version_difference {
                VersionDifference::TooNew => "This issue can be fixed by updating Bonnie to the appropriate version, which can be done at https://github.com/arctic-hen7/bonnie/releases.",
                VersionDifference::TooOld => "This issue can be fixed by updating the configuration file, which may require changing some of its syntax (see https://github.com/arctic-hen7/bonnie for how to do so). Alternatively, you can download an older version of Bonnie from https://github.com/arctic-hen7/bonnie/releases (not recommended)."
            }),
            // These next two are just warnings, not errors
            VersionCompatibility::DifferentMinor(version_difference) => writeln!(output, "{}", "The provided configuration file is compatible with this version of Bonnie, but has a different minor version. You are running Bonnie v".to_string() + bonnie_version_str + ", but the configuration file expects Bonnie v" + cfg_version_str + ". " + match version_difference {
                VersionDifference::TooNew => "This issue can be fixed by updating Bonnie to the appropriate version, which can be done at https://github.com/arctic-hen7/bonnie/releases.",
                VersionDifference::TooOld => "This issue can be fixed by updating the configuration file, which may require changing some of its syntax (see https://github.com/arctic-hen7/bonnie for how to do so). Alternatively, you can download an older version of Bonnie from https://github.com/arctic-hen7/bonnie/releases (not recommended)."
            }).expect("Failed to write warning."),
            VersionCompatibility::DifferentPatch(version_difference) => writeln!(output, "{}", "The provided configuration file is compatible with this version of Bonnie, but has a different patch version. You are running Bonnie v".to_string() + bonnie_version_str + ", but the configuration file expects Bonnie v" + cfg_version_str + ". " + match version_difference {
                VersionDifference::TooNew => "You may want to update Bonnie to the appropriate version, which can be done at https://github.com/arctic-hen7/bonnie/releases.",
                VersionDifference::TooOld => "You may want to update the configuration file (which shouldn't require any syntax changes)."
            }).expect("Failed to write warning."),
            _ => ()
        };
        // If we haven't returned an error yet, the version is valid (and warnings have been emitted as necessary)
        Ok(())
    }
pub fn parse_version_against_current ( cfg_version_str : & str , bonnie_version_str : & str , output : & mut impl std :: io :: Write , ) -> Result < ( ) , String > { // Split the program and config file versions into their components let bonnie_version = get_version_parts ( bonnie_version_str ) ? ; let cfg_version = get_version_parts ( cfg_version_str ) ? ; // Compare the two and warn/error appropriately let compat = bonnie_version . is_compatible_with ( & cfg_version ) ; match compat { VersionCompatibility :: DifferentBetaVersion ( version_difference ) => return Err ( " " . to_string ( ) + bonnie_version_str + " " + cfg_version_str + " " + match version_difference { VersionDifference :: TooNew => " " , VersionDifference :: TooOld => " " } ) , VersionCompatibility :: DifferentMajor ( version_difference ) => return Err ( " " . to_string ( ) + bonnie_version_str + " " + cfg_version_str + " " + match version_difference { VersionDifference :: TooNew => " " , VersionDifference :: TooOld => " " } ) , // These next two are just warnings, not errors VersionCompatibility :: DifferentMinor ( version_difference ) => writeln ! ( output " " " " to_string ( ) bonnie_version_str " " cfg_version_str " " match version_difference { VersionDifference TooNew " " VersionDifference TooOld " " } ) . expect ( " " ) , VersionCompatibility :: DifferentPatch ( version_difference ) => writeln ! ( output " " " " to_string ( ) bonnie_version_str " " cfg_version_str " " match version_difference { VersionDifference TooNew " " VersionDifference TooOld " " } ) . expect ( " " ) , _ => ( ) } ; // If we haven't returned an error yet, the version is valid (and warnings have been emitted as necessary) Ok ( ( ) ) }
Parses the version of the config to check for compatibility issues, consuming `self`
We extract the version of Bonnie itself for testing purposes
This si generic because it's used in caching logic as well
Parses the version of the config to check for compatibility issues consuming ` self ` We extract the version of Bonnie itself for testing purposes This si generic because it ' s used in caching logic as well
cfg_version_str
&str
bonnie_version_str
&str
output
&mut impl std::io::Write