pub struct ForgeAsyncRuntime { /* private fields */ }
Expand description
异步编�器运行时
提供异步操作支持的编辑器运行时,包含:
- 基础编辑器功能(通过 ForgeRuntime)
- 异步流引擎(用于处理复杂的异步操作流)
配置通过基础 ForgeRuntime 访问,避免重复持有
Implementations§
Source§impl ForgeAsyncRuntime
impl ForgeAsyncRuntime
Sourcepub async fn create(options: RuntimeOptions) -> ForgeResult<Self>
pub async fn create(options: RuntimeOptions) -> ForgeResult<Self>
Sourcepub async fn from_xml_schema_path(
xml_schema_path: &str,
options: Option<RuntimeOptions>,
config: Option<ForgeConfig>,
) -> ForgeResult<Self>
pub async fn from_xml_schema_path( xml_schema_path: &str, options: Option<RuntimeOptions>, config: Option<ForgeConfig>, ) -> ForgeResult<Self>
从指定路径的XML schema文件创建异步编辑器实例
§参数
xml_schema_path
- XML schema文件路径options
- 可选的RuntimeOptions配置config
- 可选的ForgeConfig配置
§返回值
ForgeResult<Self>
- 异步编辑器实例或错误
§示例
use mf_core::ForgeAsyncRuntime;
// 从指定路径加载schema
let runtime = ForgeAsyncRuntime::from_xml_schema_path(
"./schemas/document.xml",
None,
None
).await?;
Sourcepub async fn from_xml_schemas(
xml_schema_paths: &[&str],
options: Option<RuntimeOptions>,
config: Option<ForgeConfig>,
) -> ForgeResult<Self>
pub async fn from_xml_schemas( xml_schema_paths: &[&str], options: Option<RuntimeOptions>, config: Option<ForgeConfig>, ) -> ForgeResult<Self>
Sourcepub async fn from_xml_content(
xml_content: &str,
options: Option<RuntimeOptions>,
config: Option<ForgeConfig>,
) -> ForgeResult<Self>
pub async fn from_xml_content( xml_content: &str, options: Option<RuntimeOptions>, config: Option<ForgeConfig>, ) -> ForgeResult<Self>
Sourcepub async fn create_with_config(
options: RuntimeOptions,
config: ForgeConfig,
) -> ForgeResult<Self>
pub async fn create_with_config( options: RuntimeOptions, config: ForgeConfig, ) -> ForgeResult<Self>
Sourcepub fn set_performance_config(&mut self, perf_config: PerformanceConfig)
pub fn set_performance_config(&mut self, perf_config: PerformanceConfig)
设置性能监控配置
Sourcepub fn get_config(&self) -> &ForgeConfig
pub fn get_config(&self) -> &ForgeConfig
获取当前配置
Sourcepub fn update_config(&mut self, config: ForgeConfig)
pub fn update_config(&mut self, config: ForgeConfig)
更新配置
pub async fn command(&mut self, command: Arc<dyn Command>) -> ForgeResult<()>
Sourcepub async fn command_with_meta(
&mut self,
command: Arc<dyn Command>,
description: String,
meta: Value,
) -> ForgeResult<()>
pub async fn command_with_meta( &mut self, command: Arc<dyn Command>, description: String, meta: Value, ) -> ForgeResult<()>
pub async fn dispatch_flow( &mut self, transaction: Transaction, ) -> ForgeResult<()>
Sourcepub async fn dispatch_flow_with_meta(
&mut self,
transaction: Transaction,
description: String,
meta: Value,
) -> ForgeResult<()>
pub async fn dispatch_flow_with_meta( &mut self, transaction: Transaction, description: String, meta: Value, ) -> ForgeResult<()>
pub async fn run_before_middleware( &mut self, transaction: &mut Transaction, ) -> ForgeResult<()>
pub async fn run_after_middleware( &mut self, state: &mut Option<Arc<State>>, transactions: &mut Vec<Transaction>, ) -> ForgeResult<()>
Sourcepub async fn shutdown(&mut self) -> ForgeResult<()>
pub async fn shutdown(&mut self) -> ForgeResult<()>
优雅关闭异步运行时
这个方法会:
- 停止接受新任务
- 等待所有正在处理的任务完成
- 关闭底层的异步处理器
- 清理所有资源
Methods from Deref<Target = ForgeRuntime>§
Sourcepub async fn destroy(&mut self) -> ForgeResult<()>
pub async fn destroy(&mut self) -> ForgeResult<()>
销毁编辑器实例
pub async fn emit_event(&mut self, event: Event) -> ForgeResult<()>
pub async fn run_before_middleware( &mut self, transaction: &mut Transaction, ) -> ForgeResult<()>
pub async fn run_after_middleware( &mut self, state: &mut Option<Arc<State>>, transactions: &mut Vec<Transaction>, ) -> ForgeResult<()>
pub async fn command(&mut self, command: Arc<dyn Command>) -> ForgeResult<()>
pub async fn command_with_meta( &mut self, command: Arc<dyn Command>, description: String, meta: Value, ) -> ForgeResult<()>
Sourcepub async fn dispatch(&mut self, transaction: Transaction) -> ForgeResult<()>
pub async fn dispatch(&mut self, transaction: Transaction) -> ForgeResult<()>
Sourcepub async fn dispatch_with_meta(
&mut self,
transaction: Transaction,
description: String,
meta: Value,
) -> ForgeResult<()>
pub async fn dispatch_with_meta( &mut self, transaction: Transaction, description: String, meta: Value, ) -> ForgeResult<()>
更新编辑器状态并记录到历史记录 包含描述和元信息
Sourcepub async fn update_state(&mut self, state: Arc<State>) -> ForgeResult<()>
pub async fn update_state(&mut self, state: Arc<State>) -> ForgeResult<()>
更新编辑器状态并记录到历史记录 不包含描述和元信息
Sourcepub async fn update_state_with_meta(
&mut self,
state: Arc<State>,
description: String,
meta: Value,
) -> ForgeResult<()>
pub async fn update_state_with_meta( &mut self, state: Arc<State>, description: String, meta: Value, ) -> ForgeResult<()>
更新编辑器状态并记录到历史记录 包含描述和元信息
pub async fn register_plugin(&mut self) -> ForgeResult<()>
pub async fn unregister_plugin(&mut self, plugin_key: String) -> ForgeResult<()>
pub fn get_options(&self) -> &RuntimeOptions
Sourcepub fn get_config(&self) -> &ForgeConfig
pub fn get_config(&self) -> &ForgeConfig
获取当前配置
Sourcepub fn update_config(&mut self, config: ForgeConfig)
pub fn update_config(&mut self, config: ForgeConfig)
更新配置
pub fn get_state(&self) -> &Arc<State>
pub fn get_schema(&self) -> Arc<Schema>
pub fn get_event_bus(&self) -> &EventBus<Event>
pub fn get_tr(&self) -> Transaction
pub fn undo(&mut self)
pub fn redo(&mut self)
pub fn jump(&mut self, n: isize)
pub fn get_history_manager(&self) -> &HistoryManager<HistoryEntryWithMeta>
Trait Implementations§
Source§impl Deref for ForgeAsyncRuntime
impl Deref for ForgeAsyncRuntime
Source§impl DerefMut for ForgeAsyncRuntime
impl DerefMut for ForgeAsyncRuntime
impl Send for ForgeAsyncRuntime
impl Sync for ForgeAsyncRuntime
Auto Trait Implementations§
impl Freeze for ForgeAsyncRuntime
impl !RefUnwindSafe for ForgeAsyncRuntime
impl !Unpin for ForgeAsyncRuntime
impl !UnwindSafe for ForgeAsyncRuntime
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> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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