pub struct Transaction {
pub meta: GenericHashMap<String, Arc<dyn Any>, RandomState, ArcK>,
pub id: u64,
/* private fields */
}
Expand description
事务结构体,用于管理文档的修改操作
Fields§
§meta: GenericHashMap<String, Arc<dyn Any>, RandomState, ArcK>
存储元数据的哈希表,支持任意类型数据
id: u64
事务的时间戳
Implementations§
Source§impl Transaction
impl Transaction
Sourcepub fn new(state: &State) -> Transaction
pub fn new(state: &State) -> Transaction
创建新的事务实例 state: 当前状态对象 返回: Transaction 实例
pub fn merge(&mut self, other: &mut Transaction)
Sourcepub fn set_node_attribute(
&mut self,
id: String,
values: GenericHashMap<String, Value, RandomState, ArcK>,
) -> Result<(), Error>
pub fn set_node_attribute( &mut self, id: String, values: GenericHashMap<String, Value, RandomState, ArcK>, ) -> Result<(), Error>
设置节点属性 id: 节点ID values: 属性键值对
Sourcepub fn add_node(
&mut self,
parent_id: String,
nodes: Vec<NodeEnum>,
) -> Result<(), Error>
pub fn add_node( &mut self, parent_id: String, nodes: Vec<NodeEnum>, ) -> Result<(), Error>
添加新节点 parent_id: 父节点ID node: 要添加的节点
Sourcepub fn remove_node(
&mut self,
parent_id: String,
node_ids: Vec<String>,
) -> Result<(), Error>
pub fn remove_node( &mut self, parent_id: String, node_ids: Vec<String>, ) -> Result<(), Error>
删除节点 id: 节点ID nodes: 要删除的节点
Sourcepub fn add_mark(&mut self, id: String, marks: Vec<Mark>) -> Result<(), Error>
pub fn add_mark(&mut self, id: String, marks: Vec<Mark>) -> Result<(), Error>
添加标记 id: 节点ID marks: 要添加的标记
Sourcepub fn remove_mark(
&mut self,
id: String,
mark_types: Vec<String>,
) -> Result<(), Error>
pub fn remove_mark( &mut self, id: String, mark_types: Vec<String>, ) -> Result<(), Error>
删除标记 id: 节点ID marks: 要删除的标记
Sourcepub fn set_meta<K, T>(&mut self, key: K, value: T) -> &mut Transaction
pub fn set_meta<K, T>(&mut self, key: K, value: T) -> &mut Transaction
设置元数据 key: 键 value: 值(支持任意类型)
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 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
Source§impl DerefMut for Transaction
impl DerefMut for Transaction
impl Send for Transaction
impl Sync for Transaction
Auto Trait Implementations§
impl Freeze for Transaction
impl !RefUnwindSafe 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