pub struct Transaction {
pub meta: HashTrieMapSync<String, Arc<dyn Any + Send + Sync>>,
pub id: u64,
/* private fields */
}Expand description
事务结构体,用于管理文档的修改操作
Fields§
§meta: HashTrieMapSync<String, Arc<dyn Any + Send + Sync>>存储元数据的哈希表,支持任意类型数据
id: u64Implementations§
Source§impl Transaction
impl Transaction
pub fn merge(&mut self, other: &mut Self)
Sourcepub fn set_node_attribute(
&mut self,
id: NodeId,
values: HashTrieMapSync<String, Value>,
) -> TransformResult<()>
pub fn set_node_attribute( &mut self, id: NodeId, values: HashTrieMapSync<String, Value>, ) -> TransformResult<()>
设置节点属性 id: 节点ID values: 属性键值对
Sourcepub fn add_node(
&mut self,
parent_id: NodeId,
nodes: Vec<NodeTree>,
) -> TransformResult<()>
pub fn add_node( &mut self, parent_id: NodeId, nodes: Vec<NodeTree>, ) -> TransformResult<()>
添加新节点 parent_id: 父节点ID node: 要添加的节点
Sourcepub fn remove_node(
&mut self,
parent_id: NodeId,
node_ids: Vec<NodeId>,
) -> TransformResult<()>
pub fn remove_node( &mut self, parent_id: NodeId, node_ids: Vec<NodeId>, ) -> TransformResult<()>
删除节点 id: 节点ID nodes: 要删除的节点
Sourcepub fn add_mark(&mut self, id: NodeId, marks: Vec<Mark>) -> TransformResult<()>
pub fn add_mark(&mut self, id: NodeId, marks: Vec<Mark>) -> TransformResult<()>
添加标记 id: 节点ID marks: 要添加的标记
Sourcepub fn remove_mark(
&mut self,
id: NodeId,
mark_types: Vec<String>,
) -> TransformResult<()>
pub fn remove_mark( &mut self, id: NodeId, mark_types: Vec<String>, ) -> TransformResult<()>
删除标记 id: 节点ID marks: 要删除的标记
Methods from Deref<Target = Transform>§
pub fn step(&mut self, step: Arc<dyn Step>) -> Result<(), Error>
Sourcepub fn doc_changed(&self) -> bool
pub fn doc_changed(&self) -> bool
检查文档是否被修改
Sourcepub fn apply_steps_batch(
&mut self,
steps: Vec<Arc<dyn Step>>,
) -> Result<(), Error>
pub fn apply_steps_batch( &mut self, steps: Vec<Arc<dyn Step>>, ) -> Result<(), Error>
批量应用步骤(优化版本)
Sourcepub fn commit(&mut self) -> Result<(), Error>
pub fn commit(&mut self) -> Result<(), Error>
提交更改,将当前状态设为新的基础状态 保留历史记录(steps 和 invert_steps)以支持回滚功能 返回 TransformResult 以处理状态错误
Sourcepub fn clear_history(&mut self)
pub fn clear_history(&mut self)
清除历史记录(释放内存)
Sourcepub fn history_size(&self) -> usize
pub fn history_size(&self) -> usize
获取历史记录大小
Trait Implementations§
Source§impl Clone for Transaction
impl Clone for Transaction
Source§fn clone(&self) -> Transaction
fn clone(&self) -> Transaction
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for Transaction
impl Debug for Transaction
Source§impl Deref for Transaction
impl Deref for Transaction
Auto Trait Implementations§
impl Freeze for Transaction
impl !RefUnwindSafe for Transaction
impl Send for Transaction
impl Sync for Transaction
impl Unpin for Transaction
impl !UnwindSafe for Transaction
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