pub struct Graph { /* private fields */ }Implementations§
Source§impl Graph
impl Graph
pub fn new() -> Self
pub fn alloc_node_id(&mut self) -> NodeId
pub fn alloc_port_id(&mut self) -> PortId
pub fn alloc_edge_id(&mut self) -> EdgeId
pub fn node(&self, id: NodeId) -> Option<&Node>
pub fn port(&self, id: PortId) -> Option<&Port>
pub fn edge(&self, id: EdgeId) -> Option<&Edge>
pub fn node_count(&self) -> usize
pub fn edge_count(&self) -> usize
pub fn node_ids(&self) -> &[NodeId]
pub fn edges(&self) -> impl Iterator<Item = &Edge>
pub fn ports_of(&self, node: NodeId) -> impl Iterator<Item = &Port>
pub fn edges_of_port(&self, port: PortId) -> &[EdgeId]
Sourcepub fn connected_edges(&self, node: NodeId) -> Vec<EdgeId>
pub fn connected_edges(&self, node: NodeId) -> Vec<EdgeId>
与节点相连的所有边(gpui-flow get_connected_edges)。
pub fn children_of(&self, parent: NodeId) -> &[NodeId]
pub fn is_ancestor(&self, ancestor: NodeId, node: NodeId) -> bool
pub fn world_rect(&self, id: NodeId) -> Option<Rect>
Sourcepub fn to_local(&self, world: Vec2, parent: Option<NodeId>) -> Option<Vec2>
pub fn to_local(&self, world: Vec2, parent: Option<NodeId>) -> Option<Vec2>
世界坐标换算到 parent 的局部坐标。
Sourcepub fn nodes_in_rect(&self, rect: &Rect, fully: bool) -> Vec<NodeId>
pub fn nodes_in_rect(&self, rect: &Rect, fully: bool) -> Vec<NodeId>
与矩形相交(fully = false)或被完全包含(fully = true)的节点,按绘制顺序。
pub fn has_cycle(&self) -> bool
Sourcepub fn would_create_cycle(&self, from: NodeId, to: NodeId) -> bool
pub fn would_create_cycle(&self, from: NodeId, to: NodeId) -> bool
新增 from → to 是否会成环(to 能否到达 from)。
Sourcepub fn set_status(&mut self, id: NodeId, status: NodeStatus) -> bool
pub fn set_status(&mut self, id: NodeId, status: NodeStatus) -> bool
运行状态不进入撤销历史。
pub fn set_edge_state(&mut self, id: EdgeId, state: EdgeState) -> bool
Sourcepub fn bring_to_front(&mut self, id: NodeId)
pub fn bring_to_front(&mut self, id: NodeId)
置顶(含子树,保证子节点仍画在父节点之上)。
Sourcepub fn add_node_with(
&mut self,
kind: &str,
pos: Vec2,
size: Size2,
inputs: usize,
outputs: usize,
) -> (NodeId, Vec<PortId>, Vec<PortId>)
pub fn add_node_with( &mut self, kind: &str, pos: Vec2, size: Size2, inputs: usize, outputs: usize, ) -> (NodeId, Vec<PortId>, Vec<PortId>)
创建一个节点(不进历史,适合初始化)。返回节点 ID 与 (输入端口, 输出端口)。
Sourcepub fn connect(
&mut self,
from: PortId,
to: PortId,
) -> Result<EdgeId, GraphError>
pub fn connect( &mut self, from: PortId, to: PortId, ) -> Result<EdgeId, GraphError>
直接连线(不校验、不进历史,适合初始化)。
pub fn to_json(&self) -> Value
pub fn from_json(value: Value) -> Result<Self, GraphError>
Trait Implementations§
Auto Trait Implementations§
impl Forget for Graph
impl Freeze for Graphwhere
*const u8 is !null: Freeze,
PhantomData<(NodeId, Node)>: Freeze,
PhantomData<(PortId, Port)>: Freeze,
PhantomData<(EdgeId, Edge)>: Freeze,
PhantomData<NodeId>: Freeze,
PhantomData<(PortId, Vec<EdgeId>)>: Freeze,
PhantomData<(NodeId, Vec<NodeId>)>: Freeze,
impl Move for Graph
impl RefUnwindSafe for Graph
impl Send for Graph
impl Sync for Graph
impl Unpin for Graph
impl UnsafeUnpin for Graphwhere
*const u8 is !null: UnsafeUnpin,
PhantomData<(NodeId, Node)>: UnsafeUnpin,
PhantomData<(PortId, Port)>: UnsafeUnpin,
PhantomData<(EdgeId, Edge)>: UnsafeUnpin,
PhantomData<NodeId>: UnsafeUnpin,
PhantomData<(PortId, Vec<EdgeId>)>: UnsafeUnpin,
PhantomData<(NodeId, Vec<NodeId>)>: UnsafeUnpin,
impl UnwindSafe for Graphwhere
HashMap<NodeId, Node>: UnwindSafe,
HashMap<PortId, Port>: UnwindSafe,
HashMap<EdgeId, Edge>: UnwindSafe,
RawVecInner: UnwindSafe,
HashMap<PortId, Vec<EdgeId>>: UnwindSafe,
HashMap<NodeId, Vec<NodeId>>: UnwindSafe,
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