Skip to main content

Graph

Struct Graph 

Source
pub struct Graph { /* private fields */ }
Expand description

Node graph document.

Implementations§

Source§

impl Graph

Source

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}
Source

pub fn graph_id(&self) -> GraphId

Returns the stable graph identity.

Source

pub fn graph_version(&self) -> u32

Returns the schema version.

Source

pub fn imports(&self) -> GraphElements<'_, GraphId, GraphImport>

Returns graph imports.

Source

pub fn import(&self, id: &GraphId) -> Option<&GraphImport>

Returns one graph import.

Source

pub fn symbols(&self) -> GraphElements<'_, SymbolId, Symbol>

Returns graph symbols.

Source

pub fn symbol(&self, id: &SymbolId) -> Option<&Symbol>

Returns one symbol.

Source

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}
Source

pub fn node(&self, id: &NodeId) -> Option<&Node>

Returns one node.

Source

pub fn ports(&self) -> GraphElements<'_, PortId, Port>

Returns graph ports.

Source

pub fn port(&self, id: &PortId) -> Option<&Port>

Returns one port.

Source

pub fn edges(&self) -> GraphElements<'_, EdgeId, Edge>

Returns graph edges.

Source

pub fn edge(&self, id: &EdgeId) -> Option<&Edge>

Returns one edge.

Source

pub fn groups(&self) -> GraphElements<'_, GroupId, Group>

Returns graph groups.

Source

pub fn group(&self, id: &GroupId) -> Option<&Group>

Returns one group.

Source

pub fn sticky_notes(&self) -> GraphElements<'_, StickyNoteId, StickyNote>

Returns sticky notes.

Source

pub fn sticky_note(&self, id: &StickyNoteId) -> Option<&StickyNote>

Returns one sticky note.

Source

pub fn bindings(&self) -> GraphElements<'_, BindingId, Binding>

Returns bindings.

Source

pub fn binding(&self, id: &BindingId) -> Option<&Binding>

Returns one binding.

Trait Implementations§

Source§

impl AsRef<Graph> for GraphBuilder

Source§

fn as_ref(&self) -> &Graph

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl Clone for Graph

Source§

fn clone(&self) -> Graph

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Graph

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Graph

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl<'de> Deserialize<'de> for Graph

Source§

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

Source§

fn from(builder: GraphBuilder) -> Self

Converts to this type from the input type.
Source§

impl GraphOpBuilderExt for Graph

Source§

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>

Builds a RemovePort op for an existing port, including incident edges.
Source§

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>

Builds a transaction that removes a port (and its incident edges).
Source§

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>

Builds a transaction that removes a node (and its ports/edges).
Source§

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>

Builds a transaction that removes a group (and detaches any child nodes).
Source§

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>

Builds a transaction that removes a sticky note and attached bindings.
Source§

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>

Builds a transaction that removes a binding.
Source§

impl Serialize for Graph

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.