pub struct State {
pub config: Arc<Configuration>,
pub fields_instances: GenericHashMap<String, Arc<dyn Resource>, RandomState, ArcK>,
pub node_pool: Arc<NodePool>,
pub version: u64,
}
Expand description
State 结构体代表编辑器的整体状态
- 配置信息: 存储编辑器的配置信息
- 字段实例: 存储插件的状态数据
- 节点池: 文档的节点池
- 版本号: 状态版本号,用于追踪变更
Fields§
§config: Arc<Configuration>
§fields_instances: GenericHashMap<String, Arc<dyn Resource>, RandomState, ArcK>
§node_pool: Arc<NodePool>
§version: u64
Implementations§
Source§impl State
impl State
Sourcepub async fn create(state_config: StateConfig) -> Result<State, Error>
pub async fn create(state_config: StateConfig) -> Result<State, Error>
创建新的编辑器状态
- 初始化基础配置
- 初始化所有插件的状态
- 返回完整的编辑器状态实例
Sourcepub fn new(config: Arc<Configuration>) -> Result<State, Error>
pub fn new(config: Arc<Configuration>) -> Result<State, Error>
根据配置创建新的状态实例
- 如果没有提供文档,则创建一个空的顶层节点
- 初始化基本状态信息
pub fn doc(&self) -> Arc<NodePool>
Sourcepub fn resource_manager(&self) -> Arc<GlobalResourceManager>
pub fn resource_manager(&self) -> Arc<GlobalResourceManager>
获取资源管理器
Sourcepub fn sorted_plugins(&self) -> &Vec<Arc<Plugin>>
pub fn sorted_plugins(&self) -> &Vec<Arc<Plugin>>
获取已排序的插件列表 按照优先级排序,优先级低的先执行
Sourcepub async fn apply(
&self,
transaction: Transaction,
) -> Result<TransactionResult, Error>
pub async fn apply( &self, transaction: Transaction, ) -> Result<TransactionResult, Error>
异步应用事务到当前状态
pub async fn filter_transaction( &self, tr: &Transaction, ignore: Option<usize>, ) -> Result<bool, Error>
Sourcepub async fn apply_transaction(
&self,
root_tr: Transaction,
) -> Result<TransactionResult, Error>
pub async fn apply_transaction( &self, root_tr: Transaction, ) -> Result<TransactionResult, Error>
异步应用事务到当前状态
Sourcepub async fn apply_inner(&self, tr: &Transaction) -> Result<State, Error>
pub async fn apply_inner(&self, tr: &Transaction) -> Result<State, Error>
异步应用内部事务
pub fn tr(&self) -> Transaction
pub async fn reconfigure( &self, state_config: StateConfig, ) -> Result<State, Error>
pub fn get_field(&self, name: &str) -> Option<Arc<dyn Resource>>
pub fn get<T>(&self, name: &str) -> Option<Arc<T>>where
T: Resource,
pub fn has_field(&self, name: &str) -> bool
Sourcepub fn serialize(&self) -> Result<StateSerialize, Error>
pub fn serialize(&self) -> Result<StateSerialize, Error>
序列化状态
Sourcepub fn deserialize(
s: &StateSerialize,
configuration: &Configuration,
) -> Result<State, Error>
pub fn deserialize( s: &StateSerialize, configuration: &Configuration, ) -> Result<State, Error>
反序列化状态
Trait Implementations§
Auto Trait Implementations§
impl Freeze for State
impl !RefUnwindSafe for State
impl Send for State
impl Sync for State
impl Unpin for State
impl !UnwindSafe for State
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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