#[non_exhaustive]pub enum Mirror {
Official,
Bmclapi,
Mcim,
China,
Combined(Vec<Mirror>),
Custom(Vec<RewriteRule>),
}http only.Expand description
Mirror routing strategy applied to outbound URLs.
Built-in route tables follow:
- BMCLAPI: https://bmclapidoc.bangbang93.com/
- MCIMirror: https://docs.mcimirror.top/
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Official
Use official upstream endpoints directly.
Bmclapi
Route Mojang, Piston, Fabric, Quilt, Forge, NeoForge, LiteLoader, and authlib-injector URLs through BMCLAPI.
Mcim
Route Modrinth and CurseForge API and download CDN URLs through MCIMirror.
China
Combines BMCLAPI (Mojang/Loaders/ALI) and MCIM (Modrinth/CurseForge).
Zero-allocation preset equivalent to Mirror::Combined(vec![Mirror::Bmclapi, Mirror::Mcim]).
Combined(Vec<Mirror>)
Applies multiple mirrors in order (first matching rule wins).
Custom(Vec<RewriteRule>)
Applies custom prefix rewrite rules in order.
Implementations§
Source§impl Mirror
impl Mirror
Sourcepub fn rewrite_url(&self, url: &str) -> String
pub fn rewrite_url(&self, url: &str) -> String
Rewrites url according to this mirror configuration, returning the original URL
if no rule matches.
use mcapi::Mirror;
assert_eq!(
Mirror::Bmclapi.rewrite_url("https://piston-meta.mojang.com/mc/game/version_manifest_v2.json"),
"https://bmclapi2.bangbang93.com/mc/game/version_manifest_v2.json"
);Sourcepub fn is_rewritten(&self, url: &str) -> bool
pub fn is_rewritten(&self, url: &str) -> bool
Returns true if self rewrites url to a different target URL.
Sourcepub fn candidate_urls(&self, official_url: &str) -> Vec<String>
pub fn candidate_urls(&self, official_url: &str) -> Vec<String>
Returns all distinct candidate URLs for official_url in priority order
(matching mirror URLs first, followed by official_url as the final fallback).