pub struct NodeKindKey(pub String);Expand description
Stable identifier for a node kind.
This is a namespaced string identifier (e.g. core.math.add, plugin.acme.http_request).
Tuple Fields§
§0: StringImplementations§
Source§impl NodeKindKey
impl NodeKindKey
Sourcepub fn new(key: impl Into<String>) -> Self
pub fn new(key: impl Into<String>) -> Self
Creates a new node kind key.
Examples found in repository?
examples/build_graph.rs (line 7)
5fn make_node(kind: &str, x: f32, y: f32) -> Node {
6 Node {
7 kind: NodeKindKey::new(kind),
8 kind_version: 1,
9 pos: CanvasPoint { x, y },
10 origin: None,
11 selectable: None,
12 focusable: None,
13 draggable: None,
14 connectable: None,
15 deletable: None,
16 parent: None,
17 extent: None,
18 expand_parent: None,
19 size: Some(CanvasSize {
20 width: 160.0,
21 height: 80.0,
22 }),
23 hidden: false,
24 collapsed: false,
25 ports: Vec::new(),
26 data: serde_json::json!({
27 "label": kind,
28 }),
29 }
30}
31
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!(graph.nodes[&node_id].kind, NodeKindKey::new("demo.source"));
45}Trait Implementations§
Source§impl Clone for NodeKindKey
impl Clone for NodeKindKey
Source§fn clone(&self) -> NodeKindKey
fn clone(&self) -> NodeKindKey
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for NodeKindKey
impl Debug for NodeKindKey
Source§impl<'de> Deserialize<'de> for NodeKindKey
impl<'de> Deserialize<'de> for NodeKindKey
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
impl Eq for NodeKindKey
Source§impl Hash for NodeKindKey
impl Hash for NodeKindKey
Source§impl Ord for NodeKindKey
impl Ord for NodeKindKey
Source§fn cmp(&self, other: &NodeKindKey) -> Ordering
fn cmp(&self, other: &NodeKindKey) -> Ordering
1.21.0 (const: unstable) · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the maximum of two values. Read more
Source§impl PartialEq for NodeKindKey
impl PartialEq for NodeKindKey
Source§fn eq(&self, other: &NodeKindKey) -> bool
fn eq(&self, other: &NodeKindKey) -> bool
Tests for
self and other values to be equal, and is used by ==.Source§impl PartialOrd for NodeKindKey
impl PartialOrd for NodeKindKey
Source§impl Serialize for NodeKindKey
impl Serialize for NodeKindKey
impl StructuralPartialEq for NodeKindKey
Auto Trait Implementations§
impl Freeze for NodeKindKey
impl RefUnwindSafe for NodeKindKey
impl Send for NodeKindKey
impl Sync for NodeKindKey
impl Unpin for NodeKindKey
impl UnsafeUnpin for NodeKindKey
impl UnwindSafe for NodeKindKey
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