Skip to main content

VersionBuilder

Struct VersionBuilder 

Source
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 of game_dirs until overridden
  • java_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>

Source

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");
Source

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();
Source

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"));
Source

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);
Source

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");
Source

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");
Source

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>

Source§

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)

Performs copy-assignment from source. Read more
Source§

impl<L: Debug> Debug for VersionBuilder<L>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'b, L: Clone + Send + Sync + Debug> VersionInfo for &'b VersionBuilder<L>

Source§

type LoaderType = L

Source§

fn name(&self) -> &str

Instance name (unique profile identifier).
Source§

fn loader_version(&self) -> &str

Loader version (or server URL for LightyVersionBuilder).
Source§

fn minecraft_version(&self) -> &str

Minecraft version.
Source§

fn game_dirs(&self) -> &Path

Instance root directory (holds runtime/, libraries/, assets/, .forge/ etc.).
Source§

fn java_dirs(&self) -> &Path

Java directory (holds JRE installations).
Source§

fn loader(&self) -> &Self::LoaderType

Returns the loader.
Source§

fn runtime_dir(&self) -> &Path

Working directory the JVM is launched in — the value passed as ${game_directory} to the Minecraft client. Read more
Source§

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)

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

Returns whether the game directory exists on disk.
Source§

fn java_dir_exists(&self) -> bool

Returns whether the Java directory exists on disk.
Source§

fn full_identifier(&self) -> String

Returns a fully qualified version identifier. Read more
Source§

fn paths(&self) -> (&Path, &Path)

Returns the (game_dir, java_dir) tuple.
Source§

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>

Source§

type LoaderType = L

Source§

fn name(&self) -> &str

Instance name (unique profile identifier).
Source§

fn loader_version(&self) -> &str

Loader version (or server URL for LightyVersionBuilder).
Source§

fn minecraft_version(&self) -> &str

Minecraft version.
Source§

fn game_dirs(&self) -> &Path

Instance root directory (holds runtime/, libraries/, assets/, .forge/ etc.).
Source§

fn java_dirs(&self) -> &Path

Java directory (holds JRE installations).
Source§

fn loader(&self) -> &Self::LoaderType

Returns the loader.
Source§

fn runtime_dir(&self) -> &Path

Working directory the JVM is launched in — the value passed as ${game_directory} to the Minecraft client. Read more
Source§

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

TTL applied to every cache entry the launcher associates with this instance. Default = 24h.
Source§

fn game_dir_exists(&self) -> bool

Returns whether the game directory exists on disk.
Source§

fn java_dir_exists(&self) -> bool

Returns whether the Java directory exists on disk.
Source§

fn full_identifier(&self) -> String

Returns a fully qualified version identifier. Read more
Source§

fn paths(&self) -> (&Path, &Path)

Returns the (game_dir, java_dir) tuple.
Source§

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>

Source§

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>

Source§

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> InstanceCache for T
where T: VersionInfo<LoaderType = Loader> + WithMods + Send + Sync,

Source§

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

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> LoaderExtensions for T
where T: VersionInfo<LoaderType = Loader> + Send + Sync,

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,

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,

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,

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,

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,

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,

Get assets information (Vanilla-based loaders only).
Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> ErasedDestructor for T
where T: 'static,

Source§

impl<T> MaybeSendSync for T