pub enum LoadedPlugin {
Standard(Plugin),
Localized(LocalizedPluginContext),
}Expand description
插件加载结果
根据插件是否设置 LOCALIZED 标志,自动选择合适的加载方式。
Variants§
Standard(Plugin)
普通插件(未设置 LOCALIZED 标志)
Localized(LocalizedPluginContext)
本地化插件(设置了 LOCALIZED 标志,已加载 STRING 文件)
Implementations§
Source§impl LoadedPlugin
impl LoadedPlugin
Sourcepub fn load_auto(
path: PathBuf,
language: Option<&str>,
) -> Result<Self, Box<dyn Error>>
pub fn load_auto( path: PathBuf, language: Option<&str>, ) -> Result<Self, Box<dyn Error>>
智能加载插件
自动检测插件类型并选择合适的加载策略:
- 如果插件设置了 LOCALIZED 标志 → 加载为
LocalizedPluginContext - 如果是普通插件 → 加载为
Plugin
§参数
path- ESP/ESM/ESL 文件路径language- 语言标识(仅对本地化插件有效),默认 “english”
§返回
返回 LoadedPlugin 枚举,可通过模式匹配处理
§示例
ⓘ
use esp_extractor::LoadedPlugin;
let loaded = LoadedPlugin::load_auto("MyMod.esp".into(), Some("english"))?;
match loaded {
LoadedPlugin::Standard(plugin) => {
println!("普通插件: {}", plugin.get_name());
}
LoadedPlugin::Localized(context) => {
println!("本地化插件: {}", context.plugin().get_name());
println!("STRING 文件数: {}", context.string_files().files.len());
}
}Sourcepub fn into_plugin(self) -> Plugin
pub fn into_plugin(self) -> Plugin
转移所有权获取底层 Plugin(无论哪种类型)
如果是本地化插件,将丢弃 StringFileSet。
如果需要保留 STRING 文件,使用 match 解构 LoadedPlugin 获取完整的 LocalizedPluginContext。
Sourcepub fn is_localized(&self) -> bool
pub fn is_localized(&self) -> bool
检查是否为本地化插件
Source§impl LoadedPlugin
impl LoadedPlugin
Sourcepub fn extract_strings(&self) -> Vec<ExtractedString>
pub fn extract_strings(&self) -> Vec<ExtractedString>
提取字符串(自动处理本地化/非本地化)
Sourcepub fn get_stats(&self) -> PluginStats
pub fn get_stats(&self) -> PluginStats
获取统计信息
Trait Implementations§
Auto Trait Implementations§
impl Freeze for LoadedPlugin
impl RefUnwindSafe for LoadedPlugin
impl Send for LoadedPlugin
impl Sync for LoadedPlugin
impl Unpin for LoadedPlugin
impl UnwindSafe for LoadedPlugin
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> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more