pub struct ForgeRuntime { /* private fields */ }Expand description
Editor 结构体代表编辑器的核心功能实现 负责管理文档状态、事件处理、插件系统和存储等核心功能
Implementations§
Source§impl ForgeRuntime
impl ForgeRuntime
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>
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>
从XML内容字符串创建编辑器实例
§参数
xml_content- XML schema内容options- 可选的RuntimeOptions配置config- 可选的ForgeConfig配置
§返回值
ForgeResult<Self>- 编辑器实例或错误
§示例
use mf_core::{ForgeRuntime, types::RuntimeOptions};
let xml = r#"<schema>...</schema>"#;
// 使用默认选项
let runtime = ForgeRuntime::from_xml_content(xml, None, None).await?;
// 使用自定义选项
let mut options = RuntimeOptions::default();
options.set_history_limit(Some(100));
let runtime = ForgeRuntime::from_xml_content(xml, Some(options), None).await?;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 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<Arc<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>,
transactions: Vec<Arc<Transaction>>,
description: String,
meta: Value,
) -> ForgeResult<()>
pub async fn update_state_with_meta( &mut self, state: Arc<State>, transactions: Vec<Arc<Transaction>>, 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 Drop for ForgeRuntime
impl Drop for ForgeRuntime
Source§impl RuntimeTrait for ForgeRuntime
impl RuntimeTrait for ForgeRuntime
Source§fn dispatch<'life0, 'async_trait>(
&'life0 mut self,
transaction: Transaction,
) -> Pin<Box<dyn Future<Output = ForgeResult<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn dispatch<'life0, 'async_trait>(
&'life0 mut self,
transaction: Transaction,
) -> Pin<Box<dyn Future<Output = ForgeResult<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
分发事务到运行时处理 Read more
Source§fn dispatch_with_meta<'life0, 'async_trait>(
&'life0 mut self,
transaction: Transaction,
description: String,
meta: Value,
) -> Pin<Box<dyn Future<Output = ForgeResult<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn dispatch_with_meta<'life0, 'async_trait>(
&'life0 mut self,
transaction: Transaction,
description: String,
meta: Value,
) -> Pin<Box<dyn Future<Output = ForgeResult<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
分发事务(包含元信息) Read more
Source§fn command<'life0, 'async_trait>(
&'life0 mut self,
command: Arc<dyn Command>,
) -> Pin<Box<dyn Future<Output = ForgeResult<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn command<'life0, 'async_trait>(
&'life0 mut self,
command: Arc<dyn Command>,
) -> Pin<Box<dyn Future<Output = ForgeResult<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
执行命令 Read more
Source§fn command_with_meta<'life0, 'async_trait>(
&'life0 mut self,
command: Arc<dyn Command>,
description: String,
meta: Value,
) -> Pin<Box<dyn Future<Output = ForgeResult<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn command_with_meta<'life0, 'async_trait>(
&'life0 mut self,
command: Arc<dyn Command>,
description: String,
meta: Value,
) -> Pin<Box<dyn Future<Output = ForgeResult<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
执行命令(包含元信息)
Source§fn get_state<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = ForgeResult<Arc<State>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn get_state<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = ForgeResult<Arc<State>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
获取当前状态 Read more
Source§fn get_tr<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = ForgeResult<Transaction>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn get_tr<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = ForgeResult<Transaction>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
获取新事务 Read more
Source§fn get_schema<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = ForgeResult<Arc<Schema>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn get_schema<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = ForgeResult<Arc<Schema>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
获取Schema Read more
Source§fn undo<'life0, 'async_trait>(
&'life0 mut self,
) -> Pin<Box<dyn Future<Output = ForgeResult<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn undo<'life0, 'async_trait>(
&'life0 mut self,
) -> Pin<Box<dyn Future<Output = ForgeResult<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
撤销操作 Read more
Source§fn redo<'life0, 'async_trait>(
&'life0 mut self,
) -> Pin<Box<dyn Future<Output = ForgeResult<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn redo<'life0, 'async_trait>(
&'life0 mut self,
) -> Pin<Box<dyn Future<Output = ForgeResult<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
重做操作 Read more
Source§fn jump<'life0, 'async_trait>(
&'life0 mut self,
steps: isize,
) -> Pin<Box<dyn Future<Output = ForgeResult<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn jump<'life0, 'async_trait>(
&'life0 mut self,
steps: isize,
) -> Pin<Box<dyn Future<Output = ForgeResult<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
跳转到指定历史位置 Read more
Source§fn get_config(&self) -> &ForgeConfig
fn get_config(&self) -> &ForgeConfig
获取运行时配置
Source§fn update_config(&mut self, config: ForgeConfig)
fn update_config(&mut self, config: ForgeConfig)
更新运行时配置
Source§fn get_options(&self) -> &RuntimeOptions
fn get_options(&self) -> &RuntimeOptions
获取运行时选项
Auto Trait Implementations§
impl Freeze for ForgeRuntime
impl !RefUnwindSafe for ForgeRuntime
impl Send for ForgeRuntime
impl Sync for ForgeRuntime
impl !Unpin for ForgeRuntime
impl !UnwindSafe for ForgeRuntime
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 moreSource§impl<T> Message for T
impl<T> Message for T
Source§fn from_boxed(m: BoxedMessage) -> Result<Self, BoxedDowncastErr>
fn from_boxed(m: BoxedMessage) -> Result<Self, BoxedDowncastErr>
Convert a BoxedMessage to this concrete type
Source§fn box_message(self, pid: &ActorId) -> Result<BoxedMessage, BoxedDowncastErr>
fn box_message(self, pid: &ActorId) -> Result<BoxedMessage, BoxedDowncastErr>
Convert this message to a BoxedMessage