#![allow(dead_code)] //! Constants module for the DML Launcher. //! //! This module defines immutable configuration values and defaults //! used throughout the launcher. These constants provide a single //! source of truth for URLs, download behavior, memory settings, //! JVM defaults, download concurrency, directory names, and version selection. //! //! Centralizing these constants ensures consistency across the //! application and simplifies maintenance when defaults need to change. use std::time::Duration; /// URL to the Minecraft version manifest. /// /// This manifest contains metadata for all available Minecraft /// releases, including release dates, type (release, snapshot), /// and download URLs for the client and server distributions. pub const VERSION_MANIFEST_URL: &str = "https://launchermeta.mojang.com/mc/game/version_manifest.json"; /// Number of times to retry a failed download. /// /// Used by asset and library download routines to tolerate /// transient network failures. Downloads will be retried /// up to this number of attempts before returning an error. pub const DOWNLOAD_RETRIES: usize = 3; /// Duration to wait between download retries. /// /// Provides fixed delay for network resilience when fetching /// game assets. Specified in milliseconds. pub const DOWNLOAD_BACKOFF: Duration = Duration::from_millis(400); /// Default maximum memory allocation for the Minecraft JVM process in /// megabytes. /// /// If the user does not specify memory settings via configuration /// or JVM arguments, this value will be applied as the default heap size. pub const DEFAULT_MAX_MEMORY_MB: u32 = 4048; /// Default path to the Java executable. /// /// Used when launching the Minecraft client. Can be overridden /// via configuration or environment variables if a custom Java /// installation is required. pub const DEFAULT_JAVA_PATH: &str = "java"; /// Default Minecraft version to launch when no specific version is provided. /// /// The launcher will resolve "latest" to the most recent stable release /// according to the version manifest. pub const DEFAULT_VERSION: &str = "latest"; /// Default Java major version for launching Minecraft. /// /// This value is used when generating the JVM runtime configuration /// for the launcher. pub const DEFAULT_JAVA_MAJOR: u8 = 8; /// Default number of concurrent downloads for libraries. /// /// Limits the number of simultaneous HTTP requests when fetching /// Minecraft libraries to avoid saturating network or file handles. pub const DEFAULT_LIBRARY_CONCURRENCY: usize = 20; /// Default number of concurrent downloads for assets. /// /// Limits the number of simultaneous HTTP requests when fetching /// Minecraft assets to optimize throughput without overloading the system. pub const DEFAULT_ASSET_CONCURRENCY: usize = 20; /// Default launcher cache directory name. /// /// Used as the base subdirectory for downloaded assets, libraries, /// versions, and configuration. pub const DEFAULT_LAUNCHER_DIR: &str = "dml"; /// Default environment variable names for overriding configuration. pub const ENV_USERNAME: &str = "MC_USERNAME"; pub const ENV_VERSION: &str = "MC_VERSION"; pub const ENV_JAVA_PATH: &str = "MC_JAVA_PATH"; pub const ENV_MAX_MEMORY_MB: &str = "MC_MAX_MEMORY_MB"; /// Default project/platform constants for `directories::ProjectDirs`. pub const DEFAULT_COMPANY: &str = "com"; pub const DEFAULT_PROJECT_GROUP: &str = "example"; pub const DEFAULT_PROJECT_NAME: &str = "dml"; /// Default error messages for common failures. pub const DEFAULT_ERR_PLATFORM_DIR: &str = "cannot determine config dir"; pub const DEFAULT_ERR_CREATE_DIR: &str = "failed to create directory"; /// Default configuration filename within the launcher directory. pub const DEFAULT_CONFIG_FILENAME: &str = "config.toml"; /// Default username if none is provided by environment or config. pub const DEFAULT_USERNAME: &str = "phil"; /// Default subdirectory names within the launcher directory. pub mod directory { /// Directory for Minecraft versions. pub const VERSIONS: &str = "versions"; /// Directory for downloaded libraries. pub const LIBRARIES: &str = "libraries"; /// Directory for Minecraft assets. pub const ASSETS: &str = "assets"; /// Subdirectory for asset indexes. pub const INDEXES: &str = "indexes"; /// Subdirectory for asset objects. pub const OBJECTS: &str = "objects"; /// Directory for native libraries. pub const NATIVES: &str = "natives"; /// Directory for saved worlds. pub const SAVES: &str = "saves"; }