pub async fn load() -> Result<Self, ConfigError> {
        let dir_exists = std::fs::metadata("game").is_ok();

        if !dir_exists {
            tracing::info!("No game directory found. Creating one now at `/game`.");

            std::fs::create_dir("game")?;
        }

        let exists = std::fs::metadata("game/config.toml").is_ok();

        if !exists {
            tracing::info!("No configuration file found. Creating one now at `/game/config.toml`.");
            tracing::info!("You may need to change the default values in order to run your game.");

            let config = &toml::to_string(&Config::default())?;

            std::fs::write("game/config.toml", config)?;
        }

        let path = std::fs::read_to_string("game/config.toml")?;
        let config: Config = toml::from_str(&path)?;

        if config.game.tick_rate > 20 {
            tracing::warn!("Server tick_rate is very high. This may cause excessive CPU usage and/or performance issues.");
        }

        if config.game.save_interval < 30 {
            tracing::warn!("Server save_interval is very fast. This may cause excessive database writes and/or performance issues.");
        }

        Ok(config)
    }
/// Attempts to read in a `config.toml` file from the root directory of your game. This file is
/// required for the game to run, so this will panic if there are ANY errors.
Attempts to read in a `config.toml` file from the root directory of your game. This file is
required for the game to run, so this will panic if there are ANY errors.
Attempts to read in a ` config . toml ` file from the root directory of your game . This file is required for the game to run so this will panic if there are ANY errors .
pub async fn load() -> Result<Self, ConfigError> {
        let dir_exists = std::fs::metadata("game").is_ok();
        if !dir_exists {
            tracing::info!("No game directory found. Creating one now at `/game`.");
            std::fs::create_dir("game")?;
        }
        let exists = std::fs::metadata("game/config.toml").is_ok();
        if !exists {
            tracing::info!("No configuration file found. Creating one now at `/game/config.toml`.");
            tracing::info!("You may need to change the default values in order to run your game.");
            let config = &toml::to_string(&Config::default())?;
            std::fs::write("game/config.toml", config)?;
        }
        let path = std::fs::read_to_string("game/config.toml")?;
        let config: Config = toml::from_str(&path)?;
        if config.game.tick_rate > 20 {
            tracing::warn!("Server tick_rate is very high. This may cause excessive CPU usage and/or performance issues.");
        }
        if config.game.save_interval < 30 {
            tracing::warn!("Server save_interval is very fast. This may cause excessive database writes and/or performance issues.");
        }
        Ok(config)
    }
pub async fn load ( ) -> Result < Self , ConfigError > { let dir_exists = std :: fs :: metadata ( " " ) . is_ok ( ) ; if ! dir_exists { tracing :: info ! ( " " ) ; std :: fs :: create_dir ( " " ) ? ; } let exists = std :: fs :: metadata ( " " ) . is_ok ( ) ; if ! exists { tracing :: info ! ( " " ) ; tracing :: info ! ( " " ) ; let config = & toml :: to_string ( & Config :: default ( ) ) ? ; std :: fs :: write ( " " , config ) ? ; } let path = std :: fs :: read_to_string ( " " ) ? ; let config : Config = toml :: from_str ( & path ) ? ; if config . game . tick_rate > 20 { tracing :: warn ! ( " " ) ; } if config . game . save_interval < 30 { tracing :: warn ! ( " " ) ; } Ok ( config ) }
Attempts to read in a `config.toml` file from the root directory of your game.
Attempts to read in a ` config . toml ` file from the root directory of your game .