pub struct Downloader<R> {
    pub source: DownloadSource,
    pub game_independent: bool,
    pub verify_data: bool,
    pub java_path: String,
    pub reporter: Option<R>,
    /* private fields */
}
Expand description

下载结构,用于存储下载所需的信息,并通过附带的扩展特质下载需要的东西

Fields§

§source: DownloadSource

使用的下载源

§game_independent: bool

是否使用版本独立方式安装

这个会影响 Optifine 以模组形式的安装路径

(会被安装在 版本/mods 文件夹里还是 .minecraft/mods 文件夹里)

§verify_data: bool

是否验证已存在的文件是否正确

§java_path: String

任意的 Java 运行时执行文件目录

在安装 Forge 时会使用

§reporter: Option<R>

下载的进度报告对象

Implementations§

source§

impl<R> Downloader<R>

source

pub fn set_minecraft_path(&mut self, dot_minecraft_path: impl AsRef<Path>)

设置安装的目录,传入一个 .minecraft 文件夹路径作为参数

游戏将会被安装到此处

source

pub fn with_minecraft_path(self, dot_minecraft_path: impl AsRef<Path>) -> Self

source§

impl<R: Reporter> Downloader<R>

source

pub fn with_reporter(self, reporter: R) -> Self

设置一个进度报告对象,下载进度将会被上报给这个对象

source

pub fn with_source(self, source: DownloadSource) -> Self

设置一个下载源

source

pub fn with_java(self, java_path: String) -> Self

设置一个 Java 运行时,安装 Forge 和 Optifine 时需要用到

source

pub fn with_game_independent(self, game_independent: bool) -> Self

设置是否使用版本独立方式安装

这个会影响 Optifine 以模组形式的安装路径

(会被安装在 版本/mods 文件夹里还是 .minecraft/mods 文件夹里)

source

pub fn with_parallel_amount(self, limit: usize) -> Self

设置下载时的并发量,如果为 0 则不限制

source

pub fn with_verify_data(self) -> Self

是否强制校验已下载的文件以确认是否需要重新下载

如不强制则仅检测文件是否存在

Trait Implementations§

source§

impl<R: Reporter> AuthlibDownloadExt for Downloader<R>

source§

fn download_authlib_injector<'life0, 'life1, 'async_trait>( &'life0 self, dest_path: &'life1 str ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

下载最新版本的 Authlib Injector 并存放到指定路径,如果路径的文件夹不存在则会先创建它,如果文件已存在则会被覆盖
source§

fn install_authlib_injector<'life0, 'async_trait>( &'life0 self ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where Self: 'async_trait, 'life0: 'async_trait,

安装最新版本的 Authlib Injector
source§

impl<R: Reporter> Clone for Downloader<R>

source§

fn clone(&self) -> Self

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl<R: Debug> Debug for Downloader<R>

source§

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

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

impl<R: Reporter> Default for Downloader<R>

source§

fn default() -> Self

Returns the “default value” for a type. Read more
source§

impl<R: Reporter> FabricDownloadExt for Downloader<R>

source§

fn get_avaliable_loaders<'life0, 'life1, 'async_trait>( &'life0 self, vanilla_version: &'life1 str ) -> Pin<Box<dyn Future<Output = Result<Vec<LoaderMetaItem>>> + Send + 'async_trait>>where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

根据原版版本号获取该版本下可用的 Fabric 模组加载器
source§

fn download_library<'life0, 'life1, 'async_trait>( &'life0 self, name: &'life1 str ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

下载 Fabric 模组加载器所需的库文件
source§

fn download_fabric_pre<'life0, 'life1, 'life2, 'life3, 'async_trait>( &'life0 self, version_name: &'life1 str, version_id: &'life2 str, loader_version: &'life3 str ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, 'life3: 'async_trait,

下载 Fabric 模组加载器,安装时需要配合 download_fabric_post 来合并版本元数据
source§

fn download_fabric_post<'life0, 'life1, 'async_trait>( &'life0 self, version_name: &'life1 str ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

将 Fabric 模组加载器的版本元数据与原版版本元数据合并以完成最后安装步骤
source§

impl<R: Reporter> ForgeDownloadExt for Downloader<R>

source§

fn get_avaliable_installers<'life0, 'life1, 'async_trait>( &'life0 self, vanilla_version: &'life1 str ) -> Pin<Box<dyn Future<Output = Result<ForgeVersionsData>> + Send + 'async_trait>>where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

根据纯净版本号获取当前可用的所有 Forge 版本
source§

fn install_forge_pre<'life0, 'life1, 'life2, 'life3, 'async_trait>( &'life0 self, version_id: &'life1 str, vanilla_version: &'life2 str, forge_version: &'life3 str ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, 'life3: 'async_trait,

运行安装 Forge 模组加载器的预安装步骤 Read more
source§

fn install_forge_post<'life0, 'life1, 'life2, 'life3, 'async_trait>( &'life0 self, version_name: &'life1 str, version_id: &'life2 str, forge_version: &'life3 str ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, 'life3: 'async_trait,

运行安装 Forge 模组加载器的后安装步骤 Read more
source§

fn modify_forge_installer<'life0, 'life1, 'async_trait>( &'life0 self, from_reader: File, to_writer: File, name: &'life1 str ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

将安装器的部分信息进行修改,如版本名称,下载源等
source§

impl<R: Reporter> GameDownload<'_> for Downloader<R>

source§

fn download_game<'life0, 'life1, 'life2, 'life3, 'life4, 'life5, 'async_trait>( &'life0 self, version_name: &'life1 str, vanilla: VersionInfo, fabric: &'life2 str, quiltmc: &'life3 str, forge: &'life4 str, optifine: &'life5 str ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, 'life3: 'async_trait, 'life4: 'async_trait, 'life5: 'async_trait,

根据参数安装一个游戏,允许安装模组加载器
source§

impl<R: Reporter> OptifineDownloadExt for Downloader<R>

source§

fn get_avaliable_installers<'life0, 'life1, 'async_trait>( &'life0 self, vanilla_version: &'life1 str ) -> Pin<Box<dyn Future<Output = Result<Vec<OptifineVersionMeta>>> + Send + 'async_trait>>where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

根据纯净版本号获取当前可用的所有 Optifine 版本
source§

fn download_optifine<'life0, 'life1, 'life2, 'life3, 'life4, 'async_trait>( &'life0 self, vanilla_version: &'life1 str, optifine_type: &'life2 str, optifine_patch: &'life3 str, dest_path: &'life4 str ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, 'life3: 'async_trait, 'life4: 'async_trait,

下载 Optifine 版本
source§

fn install_optifine<'life0, 'life1, 'life2, 'life3, 'life4, 'async_trait>( &'life0 self, version_name: &'life1 str, vanilla_version: &'life2 str, optifine_type: &'life3 str, optifine_patch: &'life4 str, as_mod: bool ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, 'life3: 'async_trait, 'life4: 'async_trait,

安装 Optifine 版本
source§

impl<R: Reporter> QuiltMCDownloadExt for Downloader<R>

source§

fn get_avaliable_loaders<'life0, 'life1, 'async_trait>( &'life0 self, vanilla_version: &'life1 str ) -> Pin<Box<dyn Future<Output = Result<Vec<LoaderMetaItem>>> + Send + 'async_trait>>where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

根据原版版本号获取该版本下可用的 QuiltMC 模组加载器
source§

fn download_library<'life0, 'life1, 'async_trait>( &'life0 self, name: &'life1 str, url: String ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

下载 QuiltMC 模组加载器所需的库文件
source§

fn download_quiltmc_pre<'life0, 'life1, 'life2, 'life3, 'async_trait>( &'life0 self, version_name: &'life1 str, version_id: &'life2 str, loader_version: &'life3 str ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, 'life3: 'async_trait,

下载 QuiltMC 模组加载器,安装时需要配合 download_quiltmc_post 来合并版本元数据
source§

fn download_quiltmc_post<'life0, 'life1, 'async_trait>( &'life0 self, version_name: &'life1 str ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

将 QuiltMC 模组加载器的版本元数据与原版版本元数据合并以完成最后安装步骤
source§

impl<R: Reporter> VanillaDownloadExt for Downloader<R>

source§

fn get_avaliable_vanilla_versions<'life0, 'async_trait>( &'life0 self ) -> Pin<Box<dyn Future<Output = Result<VersionManifest>> + Send + 'async_trait>>where Self: 'async_trait, 'life0: 'async_trait,

获取现在所有可下载版本
source§

fn download_vanilla_jar<'life0, 'life1, 'life2, 'life3, 'async_trait>( &'life0 self, path: &'life1 str, save_path: &'life2 str, sha1: &'life3 str ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, 'life3: 'async_trait,

下载原版客户端 JAR 文件
source§

fn download_library<'life0, 'life1, 'async_trait>( &'life0 self, sha1: String, path: String, save_path: &'life1 str ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

下载一个依赖库,并存放到指定位置
source§

fn download_asset_index<'life0, 'life1, 'life2, 'life3, 'async_trait>( &'life0 self, name: &'life1 str, url: &'life2 str, save_path: &'life3 str ) -> Pin<Box<dyn Future<Output = Result<AssetIndexes>> + Send + 'async_trait>>where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, 'life3: 'async_trait,

下载游戏资源索引
source§

fn download_asset<'life0, 'life1, 'life2, 'life3, 'async_trait>( &'life0 self, sha1: &'life1 str, name: &'life2 str, save_path: &'life3 str, is_pre: bool, r: Option<impl 'async_trait + Reporter> ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, 'life3: 'async_trait,

下载一个游戏素材,并存放到指定位置
source§

fn download_libraries<'life0, 'life1, 'async_trait>( &'life0 self, libraries: &'life1 [Library] ) -> Pin<Box<dyn Future<Output = Result<HashMap<String, Vec<String>>>> + Send + 'async_trait>>where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

下载一组依赖库,安装位置由特质实现而定
source§

fn download_vanilla<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, version_name: &'life1 str, version_meta: &'life2 VersionMeta, is_repair: bool ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

下载一个游戏版本
source§

fn install_vanilla<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, version_name: &'life1 str, version_info: &'life2 VersionInfo ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

安装一个游戏版本

Auto Trait Implementations§

§

impl<R> RefUnwindSafe for Downloader<R>where R: RefUnwindSafe,

§

impl<R> Send for Downloader<R>where R: Send,

§

impl<R> Sync for Downloader<R>where R: Sync,

§

impl<R> Unpin for Downloader<R>where R: Unpin,

§

impl<R> UnwindSafe for Downloader<R>where R: UnwindSafe,

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

source§

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

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

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

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

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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 Twhere 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> Same<T> for T

§

type Output = T

Should always be Self
source§

impl<T> ToOwned for Twhere T: Clone,

§

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 Twhere U: Into<T>,

§

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 Twhere U: TryFrom<T>,

§

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.
§

impl<V, T> VZip<V> for Twhere V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

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
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more
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