use crate::core::{BindingId, EdgeId, Graph, GroupId, NodeId, PortId, StickyNoteId};
use crate::ops::{GraphMutationPlanner, GraphOp, GraphTransaction};
pub trait GraphOpBuilderExt {
fn build_remove_edge_op(&self, id: EdgeId) -> Option<GraphOp>;
fn build_remove_port_op(&self, id: PortId) -> Option<GraphOp>;
fn build_disconnect_port_ops(&self, id: PortId) -> Option<Vec<GraphOp>>;
fn build_remove_port_tx(
&self,
id: PortId,
label: impl Into<String>,
) -> Option<GraphTransaction>;
fn build_remove_node_op(&self, id: NodeId) -> Option<GraphOp>;
fn build_remove_node_tx(
&self,
id: NodeId,
label: impl Into<String>,
) -> Option<GraphTransaction>;
fn build_remove_group_op(&self, id: GroupId) -> Option<GraphOp>;
fn build_remove_group_tx(
&self,
id: GroupId,
label: impl Into<String>,
) -> Option<GraphTransaction>;
fn build_remove_sticky_note_op(&self, id: StickyNoteId) -> Option<GraphOp>;
fn build_remove_sticky_note_tx(
&self,
id: StickyNoteId,
label: impl Into<String>,
) -> Option<GraphTransaction>;
fn build_remove_binding_op(&self, id: BindingId) -> Option<GraphOp>;
fn build_remove_binding_tx(
&self,
id: BindingId,
label: impl Into<String>,
) -> Option<GraphTransaction>;
}
impl GraphOpBuilderExt for Graph {
fn build_remove_edge_op(&self, id: EdgeId) -> Option<GraphOp> {
GraphMutationPlanner::new(self).remove_edge_op(id).ok()
}
fn build_remove_port_op(&self, id: PortId) -> Option<GraphOp> {
GraphMutationPlanner::new(self).remove_port_op(id).ok()
}
fn build_disconnect_port_ops(&self, id: PortId) -> Option<Vec<GraphOp>> {
GraphMutationPlanner::new(self).disconnect_port_ops(id).ok()
}
fn build_remove_port_tx(
&self,
id: PortId,
label: impl Into<String>,
) -> Option<GraphTransaction> {
GraphMutationPlanner::new(self)
.remove_port_tx(id, label)
.ok()
}
fn build_remove_node_op(&self, id: NodeId) -> Option<GraphOp> {
GraphMutationPlanner::new(self).remove_node_op(id).ok()
}
fn build_remove_node_tx(
&self,
id: NodeId,
label: impl Into<String>,
) -> Option<GraphTransaction> {
GraphMutationPlanner::new(self)
.remove_node_tx(id, label)
.ok()
}
fn build_remove_group_op(&self, id: GroupId) -> Option<GraphOp> {
GraphMutationPlanner::new(self).remove_group_op(id).ok()
}
fn build_remove_group_tx(
&self,
id: GroupId,
label: impl Into<String>,
) -> Option<GraphTransaction> {
GraphMutationPlanner::new(self)
.remove_group_tx(id, label)
.ok()
}
fn build_remove_sticky_note_op(&self, id: StickyNoteId) -> Option<GraphOp> {
GraphMutationPlanner::new(self)
.remove_sticky_note_op(id)
.ok()
}
fn build_remove_sticky_note_tx(
&self,
id: StickyNoteId,
label: impl Into<String>,
) -> Option<GraphTransaction> {
GraphMutationPlanner::new(self)
.remove_sticky_note_tx(id, label)
.ok()
}
fn build_remove_binding_op(&self, id: BindingId) -> Option<GraphOp> {
GraphMutationPlanner::new(self).remove_binding_op(id).ok()
}
fn build_remove_binding_tx(
&self,
id: BindingId,
label: impl Into<String>,
) -> Option<GraphTransaction> {
GraphMutationPlanner::new(self)
.remove_binding_tx(id, label)
.ok()
}
}