pub struct VersionBuilder<L = ()> {
pub name: String,
pub loader: L,
pub loader_version: String,
pub minecraft_version: String,
pub game_dirs: PathBuf,
pub java_dirs: PathBuf,
pub runtime_dir: PathBuf,
pub mod_requests: Vec<ModRequest>,
pub ttl_override: Option<Duration>,
}Expand description
Configures a Minecraft instance: name, loader, versions, and on-disk paths.
Default directories are derived from the global AppState:
game_dirs=AppState::data_dir().join(name)runtime_dir= alias ofgame_dirsuntil overriddenjava_dirs=AppState::config_dir().join("jre")
Call AppState::init once at startup before constructing any
VersionBuilder.
Fields§
§name: String§loader: L§loader_version: String§minecraft_version: String§game_dirs: PathBuf§java_dirs: PathBuf§runtime_dir: PathBuf§mod_requests: Vec<ModRequest>§ttl_override: Option<Duration>Implementations§
Source§impl<L> VersionBuilder<L>
impl<L> VersionBuilder<L>
Sourcepub fn new(
name: &str,
loader: L,
loader_version: &str,
minecraft_version: &str,
) -> Self
pub fn new( name: &str, loader: L, loader_version: &str, minecraft_version: &str, ) -> Self
Creates a new VersionBuilder with default paths derived
from the global AppState.
Panics if AppState::init hasn’t been called yet.
§Example
use lighty_core::AppState;
use lighty_loaders::types::Loader;
use lighty_version::VersionBuilder;
AppState::init("MyLauncher").unwrap();
let builder = VersionBuilder::new("my-instance", Loader::Vanilla, "", "1.21.1");Sourcepub fn with_mod(self) -> ModSourcesBuilder<L>
pub fn with_mod(self) -> ModSourcesBuilder<L>
Opens the mod-sources sub-builder.
§Example
let builder = VersionBuilder::new("modded", Loader::Fabric, "0.16.0", "1.21.1")
.with_mod()
.done();Sourcepub fn with_custom_java_dir(self, java_dir: PathBuf) -> Self
pub fn with_custom_java_dir(self, java_dir: PathBuf) -> Self
Overrides the Java install directory.
§Example
use std::path::PathBuf;
let builder = VersionBuilder::new("my-instance", Loader::Vanilla, "", "1.21.1")
.with_custom_java_dir(PathBuf::from("/opt/java"));Sourcepub fn with_loader(self, loader: L) -> Self
pub fn with_loader(self, loader: L) -> Self
Replaces the loader.
§Example
let builder = VersionBuilder::new("my-instance", Loader::Vanilla, "", "1.21.1")
.with_loader(Loader::Fabric);Sourcepub fn with_loader_version(self, version: &str) -> Self
pub fn with_loader_version(self, version: &str) -> Self
Replaces the loader version.
§Example
let builder = VersionBuilder::new("my-instance", Loader::Fabric, "0.16.0", "1.21.1")
.with_loader_version("0.17.2");Sourcepub fn with_minecraft_version(self, version: &str) -> Self
pub fn with_minecraft_version(self, version: &str) -> Self
Replaces the Minecraft version.
§Example
let builder = VersionBuilder::new("my-instance", Loader::Vanilla, "", "1.21.1")
.with_minecraft_version("1.20.4");Sourcepub fn with_ttl_duration(self, ttl: Duration) -> Self
pub fn with_ttl_duration(self, ttl: Duration) -> Self
Overrides the TTL applied to every cache associated with this instance. Default = 24h.
§Example
use std::time::Duration;
let builder = VersionBuilder::new("my-instance", Loader::Vanilla, "", "1.21.1")
.with_ttl_duration(Duration::from_secs(3600));Trait Implementations§
Source§impl<L: Clone> Clone for VersionBuilder<L>
impl<L: Clone> Clone for VersionBuilder<L>
Source§fn clone(&self) -> VersionBuilder<L>
fn clone(&self) -> VersionBuilder<L>
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl<L: Debug> Debug for VersionBuilder<L>
impl<L: Debug> Debug for VersionBuilder<L>
Source§impl<'b, L: Clone + Send + Sync + Debug> VersionInfo for &'b VersionBuilder<L>
impl<'b, L: Clone + Send + Sync + Debug> VersionInfo for &'b VersionBuilder<L>
type LoaderType = L
Source§fn loader_version(&self) -> &str
fn loader_version(&self) -> &str
Loader version (or server URL for
LightyVersionBuilder).Source§fn minecraft_version(&self) -> &str
fn minecraft_version(&self) -> &str
Minecraft version.
Source§fn game_dirs(&self) -> &Path
fn game_dirs(&self) -> &Path
Instance root directory (holds
runtime/, libraries/,
assets/, .forge/ etc.).Source§fn loader(&self) -> &Self::LoaderType
fn loader(&self) -> &Self::LoaderType
Returns the loader.
Source§fn runtime_dir(&self) -> &Path
fn runtime_dir(&self) -> &Path
Working directory the JVM is launched in — the value passed as
${game_directory} to the Minecraft client. Read moreSource§fn ttl(&self) -> Duration
fn ttl(&self) -> Duration
TTL applied to every cache entry the launcher associates with
this instance. Default = 24h.
Source§fn set_runtime_dir(&mut self, _path: PathBuf)
fn set_runtime_dir(&mut self, _path: PathBuf)
Internal setter used by the launch runner to write the
effective runtime dir back onto a mutable builder.
Source§fn game_dir_exists(&self) -> bool
fn game_dir_exists(&self) -> bool
Returns whether the game directory exists on disk.
Source§fn java_dir_exists(&self) -> bool
fn java_dir_exists(&self) -> bool
Returns whether the Java directory exists on disk.
Source§fn full_identifier(&self) -> String
fn full_identifier(&self) -> String
Returns a fully qualified version identifier. Read more
Source§fn is_installed(&self) -> bool
fn is_installed(&self) -> bool
Returns whether the instance is installed (game directory exists).
Source§impl<L: Clone + Send + Sync + Debug> VersionInfo for VersionBuilder<L>
impl<L: Clone + Send + Sync + Debug> VersionInfo for VersionBuilder<L>
type LoaderType = L
Source§fn loader_version(&self) -> &str
fn loader_version(&self) -> &str
Loader version (or server URL for
LightyVersionBuilder).Source§fn minecraft_version(&self) -> &str
fn minecraft_version(&self) -> &str
Minecraft version.
Source§fn game_dirs(&self) -> &Path
fn game_dirs(&self) -> &Path
Instance root directory (holds
runtime/, libraries/,
assets/, .forge/ etc.).Source§fn loader(&self) -> &Self::LoaderType
fn loader(&self) -> &Self::LoaderType
Returns the loader.
Source§fn runtime_dir(&self) -> &Path
fn runtime_dir(&self) -> &Path
Working directory the JVM is launched in — the value passed as
${game_directory} to the Minecraft client. Read moreSource§fn set_runtime_dir(&mut self, path: PathBuf)
fn set_runtime_dir(&mut self, path: PathBuf)
Internal setter used by the launch runner to write the
effective runtime dir back onto a mutable builder.
Source§fn ttl(&self) -> Duration
fn ttl(&self) -> Duration
TTL applied to every cache entry the launcher associates with
this instance. Default = 24h.
Source§fn game_dir_exists(&self) -> bool
fn game_dir_exists(&self) -> bool
Returns whether the game directory exists on disk.
Source§fn java_dir_exists(&self) -> bool
fn java_dir_exists(&self) -> bool
Returns whether the Java directory exists on disk.
Source§fn full_identifier(&self) -> String
fn full_identifier(&self) -> String
Returns a fully qualified version identifier. Read more
Source§fn is_installed(&self) -> bool
fn is_installed(&self) -> bool
Returns whether the instance is installed (game directory exists).
Source§impl<'b, L: Clone + Send + Sync + Debug> WithMods for &'b VersionBuilder<L>
impl<'b, L: Clone + Send + Sync + Debug> WithMods for &'b VersionBuilder<L>
Source§fn mod_requests(&self) -> &[ModRequest]
fn mod_requests(&self) -> &[ModRequest]
User-attached mod requests pulled from Modrinth / CurseForge at install time.
Source§impl<L: Clone + Send + Sync + Debug> WithMods for VersionBuilder<L>
impl<L: Clone + Send + Sync + Debug> WithMods for VersionBuilder<L>
Source§fn mod_requests(&self) -> &[ModRequest]
fn mod_requests(&self) -> &[ModRequest]
User-attached mod requests pulled from Modrinth / CurseForge at install time.
Auto Trait Implementations§
impl<L> Freeze for VersionBuilder<L>where
L: Freeze,
impl<L> RefUnwindSafe for VersionBuilder<L>where
L: RefUnwindSafe,
impl<L> Send for VersionBuilder<L>where
L: Send,
impl<L> Sync for VersionBuilder<L>where
L: Sync,
impl<L> Unpin for VersionBuilder<L>where
L: Unpin,
impl<L> UnsafeUnpin for VersionBuilder<L>where
L: UnsafeUnpin,
impl<L> UnwindSafe for VersionBuilder<L>where
L: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> InstanceCache for T
impl<T> InstanceCache for T
Source§async fn clear_cache(&self)
async fn clear_cache(&self)
Invalidates the loader manifest cache plus the Modrinth and
CurseForge mod caches scoped to
(minecraft_version, loader).
Idempotent.Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> LoaderExtensions for T
impl<T> LoaderExtensions for T
Source§fn get_metadata<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<Arc<VersionMetaData>, QueryError>> + Send + 'async_trait>>where
'life0: 'async_trait,
T: 'async_trait,
fn get_metadata<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<Arc<VersionMetaData>, QueryError>> + Send + 'async_trait>>where
'life0: 'async_trait,
T: 'async_trait,
Get complete metadata for the current loader.
Source§fn get_libraries<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<Arc<VersionMetaData>, QueryError>> + Send + 'async_trait>>where
'life0: 'async_trait,
T: 'async_trait,
fn get_libraries<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<Arc<VersionMetaData>, QueryError>> + Send + 'async_trait>>where
'life0: 'async_trait,
T: 'async_trait,
Get only libraries metadata.
Source§fn get_main_class<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<Arc<VersionMetaData>, QueryError>> + Send + 'async_trait>>where
'life0: 'async_trait,
T: 'async_trait,
fn get_main_class<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<Arc<VersionMetaData>, QueryError>> + Send + 'async_trait>>where
'life0: 'async_trait,
T: 'async_trait,
Get main class information (Vanilla-based loaders only).
Source§fn get_natives<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<Arc<VersionMetaData>, QueryError>> + Send + 'async_trait>>where
'life0: 'async_trait,
T: 'async_trait,
fn get_natives<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<Arc<VersionMetaData>, QueryError>> + Send + 'async_trait>>where
'life0: 'async_trait,
T: 'async_trait,
Get native libraries (Vanilla-based loaders only).
Source§fn get_java_version<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<Arc<VersionMetaData>, QueryError>> + Send + 'async_trait>>where
'life0: 'async_trait,
T: 'async_trait,
fn get_java_version<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<Arc<VersionMetaData>, QueryError>> + Send + 'async_trait>>where
'life0: 'async_trait,
T: 'async_trait,
Get Java version requirement (Vanilla-based loaders only).
Source§fn get_assets<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<Arc<VersionMetaData>, QueryError>> + Send + 'async_trait>>where
'life0: 'async_trait,
T: 'async_trait,
fn get_assets<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<Arc<VersionMetaData>, QueryError>> + Send + 'async_trait>>where
'life0: 'async_trait,
T: 'async_trait,
Get assets information (Vanilla-based loaders only).