ImportAdapter

Trait ImportAdapter 

Source
pub trait ImportAdapter: Send + Sync {
    // Required methods
    fn metadata(&self) -> &AdapterMetadata;
    fn configure(&mut self, config: AdapterConfig) -> Result<()>;
    fn import_instruction(&self, data: &[u8]) -> Result<GaiaInstruction>;
    fn import_program(&self, data: &[u8]) -> Result<GaiaProgram>;
    fn validate_format(&self, data: &[u8]) -> bool;
    fn supported_extensions(&self) -> Vec<&str>;

    // Provided method
    fn cleanup(&mut self) -> Result<()> { ... }
}
Expand description

统一的导入适配器接口

定义了从特定平台格式导入到Gaia指令和程序的标准接口

Required Methods§

Source

fn metadata(&self) -> &AdapterMetadata

获取适配器元数据

Source

fn configure(&mut self, config: AdapterConfig) -> Result<()>

配置适配器

§参数
  • config - 适配器配置
§返回值

配置成功返回Ok(()),失败返回错误信息

Source

fn import_instruction(&self, data: &[u8]) -> Result<GaiaInstruction>

导入单个指令

§参数
  • data - 平台特定的指令数据
§返回值

导入成功返回Gaia指令,失败返回错误信息

Source

fn import_program(&self, data: &[u8]) -> Result<GaiaProgram>

导入完整程序

§参数
  • data - 平台特定的程序数据
§返回值

导入成功返回Gaia程序,失败返回错误信息

Source

fn validate_format(&self, data: &[u8]) -> bool

验证数据格式

§参数
  • data - 要验证的数据
§返回值

格式正确返回true,错误返回false

Source

fn supported_extensions(&self) -> Vec<&str>

获取支持的文件扩展名

§返回值

支持的文件扩展名列表

Provided Methods§

Source

fn cleanup(&mut self) -> Result<()>

清理资源

在适配器不再使用时调用,用于清理相关资源

Implementors§