pub struct Draft {
pub base: Arc<NodePool>,
pub inner: NodePoolInner,
pub patches: Vector<Patch>,
pub current_path: Vector<String>,
pub skip_record: bool,
pub begin: bool,
}
Expand description
草稿修改上下文,用于安全地修改节点池
跟踪以下信息:
- 基础版本节点池
- 当前修改的中间状态
- 生成的修改补丁
- 当前操作路径(用于嵌套数据结构)
Fields§
§base: Arc<NodePool>
§inner: NodePoolInner
§patches: Vector<Patch>
§current_path: Vector<String>
§skip_record: bool
§begin: bool
Implementations§
Source§impl Draft
impl Draft
Sourcepub fn enter_list(&mut self, index: usize) -> &mut Self
pub fn enter_list(&mut self, index: usize) -> &mut Self
进入嵌套路径(List类型索引)
Sourcepub fn update_attr(
&mut self,
id: &NodeId,
new_values: HashMap<String, String>,
) -> Result<(), PoolError>
pub fn update_attr( &mut self, id: &NodeId, new_values: HashMap<String, String>, ) -> Result<(), PoolError>
pub fn sort_children<F: FnMut(&(String, &Arc<Node>), &(String, &Arc<Node>)) -> Ordering>( &mut self, parent_id: &NodeId, compare: F, ) -> Result<(), PoolError>
pub fn replace_node( &mut self, node_id: NodeId, new_node: Arc<Node>, ) -> Result<(), PoolError>
Sourcepub fn move_node(
&mut self,
source_parent_id: &NodeId,
target_parent_id: &NodeId,
node_id: &NodeId,
position: Option<usize>,
) -> Result<(), PoolError>
pub fn move_node( &mut self, source_parent_id: &NodeId, target_parent_id: &NodeId, node_id: &NodeId, position: Option<usize>, ) -> Result<(), PoolError>
移动节点
pub fn get_node(&self, id: &NodeId) -> Option<&Arc<Node>>
pub fn children(&self, parent_id: &NodeId) -> Option<&Vector<NodeId>>
Sourcepub fn remove_node(
&mut self,
parent_id: &NodeId,
nodes: Vec<NodeId>,
) -> Result<(), PoolError>
pub fn remove_node( &mut self, parent_id: &NodeId, nodes: Vec<NodeId>, ) -> Result<(), PoolError>
Sourcepub fn commit(&self) -> StepResult
pub fn commit(&self) -> StepResult
提交修改,生成新 NodePool 和补丁列表
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Draft
impl RefUnwindSafe for Draft
impl Send for Draft
impl Sync for Draft
impl Unpin for Draft
impl UnwindSafe for Draft
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