LoadedPlugin

Enum LoadedPlugin 

Source
pub enum LoadedPlugin {
    Standard(Plugin),
    Localized(LocalizedPluginContext),
}
Expand description

插件加载结果

根据插件是否设置 LOCALIZED 标志,自动选择合适的加载方式。

Variants§

§

Standard(Plugin)

普通插件(未设置 LOCALIZED 标志)

§

Localized(LocalizedPluginContext)

本地化插件(设置了 LOCALIZED 标志,已加载 STRING 文件)

Implementations§

Source§

impl LoadedPlugin

Source

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

pub fn plugin(&self) -> &Plugin

获取底层 Plugin 的引用(无论哪种类型)

Source

pub fn into_plugin(self) -> Plugin

转移所有权获取底层 Plugin(无论哪种类型)

如果是本地化插件,将丢弃 StringFileSet。 如果需要保留 STRING 文件,使用 match 解构 LoadedPlugin 获取完整的 LocalizedPluginContext

Source

pub fn is_localized(&self) -> bool

检查是否为本地化插件

Source§

impl LoadedPlugin

Source

pub fn extract_strings(&self) -> Vec<ExtractedString>

提取字符串(自动处理本地化/非本地化)

Source

pub fn get_name(&self) -> &str

获取插件名称

Source

pub fn get_stats(&self) -> PluginStats

获取统计信息

Trait Implementations§

Source§

impl Debug for LoadedPlugin

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

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> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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> IntoEither for T

Source§

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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

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

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. 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.