pub struct Graph { /* private fields */ }Expand description
Node graph document.
Implementations§
Source§impl Graph
impl Graph
Sourcepub fn new(graph_id: GraphId) -> Self
pub fn new(graph_id: GraphId) -> Self
Creates a new, empty graph with the given id.
Examples found in repository?
examples/build_graph.rs (line 34)
32fn main() {
33 let node_id = NodeId::from_u128(2);
34 let mut graph = Graph::new(GraphId::from_u128(1));
35
36 let mut tx = GraphTransaction::new().with_label("add source node");
37 tx.push(GraphOp::AddNode {
38 id: node_id,
39 node: make_node("demo.source", 10.0, 20.0),
40 });
41 tx.apply_to(&mut graph).expect("transaction applies");
42
43 assert_eq!(graph.nodes().len(), 1);
44 assert_eq!(
45 graph.nodes()[&node_id].kind,
46 NodeKindKey::new("demo.source")
47 );
48}Sourcepub fn graph_version(&self) -> u32
pub fn graph_version(&self) -> u32
Returns the schema version.
Sourcepub fn imports(&self) -> GraphElements<'_, GraphId, GraphImport>
pub fn imports(&self) -> GraphElements<'_, GraphId, GraphImport>
Returns graph imports.
Sourcepub fn import(&self, id: &GraphId) -> Option<&GraphImport>
pub fn import(&self, id: &GraphId) -> Option<&GraphImport>
Returns one graph import.
Sourcepub fn symbols(&self) -> GraphElements<'_, SymbolId, Symbol>
pub fn symbols(&self) -> GraphElements<'_, SymbolId, Symbol>
Returns graph symbols.
Sourcepub fn nodes(&self) -> GraphElements<'_, NodeId, Node>
pub fn nodes(&self) -> GraphElements<'_, NodeId, Node>
Returns graph nodes.
Examples found in repository?
examples/build_graph.rs (line 43)
32fn main() {
33 let node_id = NodeId::from_u128(2);
34 let mut graph = Graph::new(GraphId::from_u128(1));
35
36 let mut tx = GraphTransaction::new().with_label("add source node");
37 tx.push(GraphOp::AddNode {
38 id: node_id,
39 node: make_node("demo.source", 10.0, 20.0),
40 });
41 tx.apply_to(&mut graph).expect("transaction applies");
42
43 assert_eq!(graph.nodes().len(), 1);
44 assert_eq!(
45 graph.nodes()[&node_id].kind,
46 NodeKindKey::new("demo.source")
47 );
48}Sourcepub fn ports(&self) -> GraphElements<'_, PortId, Port>
pub fn ports(&self) -> GraphElements<'_, PortId, Port>
Returns graph ports.
Sourcepub fn edges(&self) -> GraphElements<'_, EdgeId, Edge>
pub fn edges(&self) -> GraphElements<'_, EdgeId, Edge>
Returns graph edges.
Sourcepub fn groups(&self) -> GraphElements<'_, GroupId, Group>
pub fn groups(&self) -> GraphElements<'_, GroupId, Group>
Returns graph groups.
Sourcepub fn sticky_notes(&self) -> GraphElements<'_, StickyNoteId, StickyNote>
pub fn sticky_notes(&self) -> GraphElements<'_, StickyNoteId, StickyNote>
Returns sticky notes.
Sourcepub fn sticky_note(&self, id: &StickyNoteId) -> Option<&StickyNote>
pub fn sticky_note(&self, id: &StickyNoteId) -> Option<&StickyNote>
Returns one sticky note.
Sourcepub fn bindings(&self) -> GraphElements<'_, BindingId, Binding>
pub fn bindings(&self) -> GraphElements<'_, BindingId, Binding>
Returns bindings.
Trait Implementations§
Source§impl AsRef<Graph> for GraphBuilder
impl AsRef<Graph> for GraphBuilder
Source§impl<'de> Deserialize<'de> for Graph
impl<'de> Deserialize<'de> for Graph
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl From<GraphBuilder> for Graph
impl From<GraphBuilder> for Graph
Source§fn from(builder: GraphBuilder) -> Self
fn from(builder: GraphBuilder) -> Self
Converts to this type from the input type.
Source§impl GraphOpBuilderExt for Graph
impl GraphOpBuilderExt for Graph
Source§fn build_remove_edge_op(&self, id: EdgeId) -> Option<GraphOp>
fn build_remove_edge_op(&self, id: EdgeId) -> Option<GraphOp>
Builds a
RemoveEdge op for an existing edge.Source§fn build_remove_port_op(&self, id: PortId) -> Option<GraphOp>
fn build_remove_port_op(&self, id: PortId) -> Option<GraphOp>
Builds a
RemovePort op for an existing port, including incident edges.Source§fn build_disconnect_port_ops(&self, id: PortId) -> Option<Vec<GraphOp>>
fn build_disconnect_port_ops(&self, id: PortId) -> Option<Vec<GraphOp>>
Builds ops that disconnect all edges incident to the port. Read more
Source§fn build_remove_port_tx(
&self,
id: PortId,
label: impl Into<String>,
) -> Option<GraphTransaction>
fn build_remove_port_tx( &self, id: PortId, label: impl Into<String>, ) -> Option<GraphTransaction>
Builds a transaction that removes a port (and its incident edges).
Source§fn build_remove_node_op(&self, id: NodeId) -> Option<GraphOp>
fn build_remove_node_op(&self, id: NodeId) -> Option<GraphOp>
Builds a
RemoveNode op for an existing node, including owned ports and incident edges.Source§fn build_remove_node_tx(
&self,
id: NodeId,
label: impl Into<String>,
) -> Option<GraphTransaction>
fn build_remove_node_tx( &self, id: NodeId, label: impl Into<String>, ) -> Option<GraphTransaction>
Builds a transaction that removes a node (and its ports/edges).
Source§fn build_remove_group_op(&self, id: GroupId) -> Option<GraphOp>
fn build_remove_group_op(&self, id: GroupId) -> Option<GraphOp>
Builds a
RemoveGroup op for an existing group, including nodes detached from it.Source§fn build_remove_group_tx(
&self,
id: GroupId,
label: impl Into<String>,
) -> Option<GraphTransaction>
fn build_remove_group_tx( &self, id: GroupId, label: impl Into<String>, ) -> Option<GraphTransaction>
Builds a transaction that removes a group (and detaches any child nodes).
Source§fn build_remove_sticky_note_op(&self, id: StickyNoteId) -> Option<GraphOp>
fn build_remove_sticky_note_op(&self, id: StickyNoteId) -> Option<GraphOp>
Builds a
RemoveStickyNote op for an existing sticky note, including attached bindings.Source§fn build_remove_sticky_note_tx(
&self,
id: StickyNoteId,
label: impl Into<String>,
) -> Option<GraphTransaction>
fn build_remove_sticky_note_tx( &self, id: StickyNoteId, label: impl Into<String>, ) -> Option<GraphTransaction>
Builds a transaction that removes a sticky note and attached bindings.
Source§fn build_remove_binding_op(&self, id: BindingId) -> Option<GraphOp>
fn build_remove_binding_op(&self, id: BindingId) -> Option<GraphOp>
Builds a
RemoveBinding op for an existing binding.Source§fn build_remove_binding_tx(
&self,
id: BindingId,
label: impl Into<String>,
) -> Option<GraphTransaction>
fn build_remove_binding_tx( &self, id: BindingId, label: impl Into<String>, ) -> Option<GraphTransaction>
Builds a transaction that removes a binding.
Auto Trait Implementations§
impl Freeze for Graph
impl RefUnwindSafe for Graph
impl Send for Graph
impl Sync for Graph
impl Unpin for Graph
impl UnsafeUnpin for Graph
impl UnwindSafe for Graph
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